_query_expr_compiler#

Defines QueryExprCompiler for compiling query expressions.

Classes#

QueryExprCompiler

Compiles a list of query expressions to a single measurement object.

class QueryExprCompiler(output_measure=PureDP())#

Compiles a list of query expressions to a single measurement object.

Requires that each query is a groupby-aggregation on a sequence of transformations on a PrivateSource or PrivateView. If there is a PrivateView, the stability of the view is handled when the noise scale is calculated.

A QueryExprCompiler object compiles a list of QueryExpr objects into a single object (based on the privacy framework). The Measurement object can be run with a private data source to obtain DP answers to supplied queries.

Supported QueryExprs:

Parameters

output_measure (Union[tmlt.core.measures.PureDP, tmlt.core.measures.RhoZCDP]) –

__init__(output_measure=PureDP())#

Constructor.

Parameters

output_measure (PureDP | RhoZCDPUnion[PureDP, RhoZCDP] (default: PureDP())) – Distance measure for measurement’s output.

property mechanism(self)#

Return the value of Core noise mechanism.

Return type

tmlt.core.measurements.aggregations.NoiseMechanism

property output_measure(self)#

Return the distance measure for the measurement’s output.

Return type

Union[tmlt.core.measures.PureDP, tmlt.core.measures.RhoZCDP]

__call__(self, queries, privacy_budget, stability, input_domain, input_metric, public_sources, catalog)#

Returns a compiled DP measurement.

Parameters
  • queries (Sequence[tmlt.analytics.query_expr.QueryExpr]) – Queries representing measurements to compile.

  • privacy_budget (sympy.Expr) – The total privacy budget for answering the queries.

  • stability (Dict[str, sympy.Expr]) – The stability of the input to compiled query.

  • input_domain (tmlt.core.domains.collections.DictDomain) – The input domain of the compiled query.

  • input_metric (tmlt.core.metrics.DictMetric) – The input metric of the compiled query.

  • public_sources (Dict[str, pyspark.sql.DataFrame]) – Public data sources for the queries.

  • catalog (tmlt.analytics._catalog.Catalog) – The catalog, used only for query validation.

Return type

tmlt.core.measurements.base.Measurement

build_transformation(self, query, input_domain, input_metric, public_sources, catalog)#

Returns a transformation for the query.

Supported QueryExprs:

Parameters
  • query (tmlt.analytics.query_expr.QueryExpr) – A query representing a transformation to compile.

  • input_domain (tmlt.core.domains.collections.DictDomain) – The input domain of the compiled query.

  • input_metric (tmlt.core.metrics.DictMetric) – The input metric of the compiled query.

  • public_sources (Dict[str, pyspark.sql.DataFrame]) – Public data sources for the queries.

  • catalog (tmlt.analytics._catalog.Catalog) – The catalog, used only for query validation.

Return type

tmlt.core.transformations.base.Transformation