converters#

Wrappers for changing a transformation’s output metric.

Classes#

UnwrapIfGroupedBy

No-op transformation for switching from IfGroupedBy to its inner metric.

HammingDistanceToSymmetricDifference

No-op transformation for switching metrics.

class UnwrapIfGroupedBy(domain, input_metric)#

Bases: tmlt.core.transformations.base.Transformation

No-op transformation for switching from IfGroupedBy to its inner metric.

Parameters
__init__(domain, input_metric)#

Constructor.

Parameters
stability_function(d_in)#

Returns the smallest d_out satisfied by the transformation.

If the inner metric of the IfGroupedBy input metric is a SumOf, returns d_in.

If the inner metric is RootSumOfSquared, returns d_in**2.

Parameters

d_in (tmlt.core.utils.exact_number.ExactNumberInput) – Distance between inputs under input_metric.

Return type

tmlt.core.utils.exact_number.ExactNumber

__call__(sdf)#

Returns DataFrame unchanged.

Parameters

sdf (pyspark.sql.DataFrame) –

Return type

pyspark.sql.DataFrame

property input_domain#

Return input domain for the measurement.

Return type

tmlt.core.domains.base.Domain

property input_metric#

Distance metric on input domain.

Return type

tmlt.core.metrics.Metric

property output_domain#

Return input domain for the measurement.

Return type

tmlt.core.domains.base.Domain

property output_metric#

Distance metric on input domain.

Return type

tmlt.core.metrics.Metric

stability_relation(d_in, d_out)#

Returns True only if close inputs produce close outputs.

See the privacy and stability tutorial (add link?) for more information.

Parameters
  • d_in (Any) – Distance between inputs under input_metric.

  • d_out (Any) – Distance between outputs under output_metric.

Return type

bool

__or__(other: Transformation) Transformation#
__or__(other: tmlt.core.measurements.base.Measurement) tmlt.core.measurements.base.Measurement

Return this transformation chained with another component.

class HammingDistanceToSymmetricDifference(domain)#

Bases: tmlt.core.transformations.base.Transformation

No-op transformation for switching metrics.

Parameters

domain (tmlt.core.domains.spark_domains.SparkDataFrameDomain) –

__init__(domain)#

Constructor.

Parameters

domain (tmlt.core.domains.spark_domains.SparkDataFrameDomain) –

stability_function(d_in)#

Returns the smallest d_out satisfied by the transformation.

Returns 2 * d_in

Parameters

d_in (tmlt.core.utils.exact_number.ExactNumberInput) – Distance between inputs under input_metric.

Return type

tmlt.core.utils.exact_number.ExactNumber

__call__(data)#

Returns unchanged input.

Parameters

data (Any) –

Return type

Any

property input_domain#

Return input domain for the measurement.

Return type

tmlt.core.domains.base.Domain

property input_metric#

Distance metric on input domain.

Return type

tmlt.core.metrics.Metric

property output_domain#

Return input domain for the measurement.

Return type

tmlt.core.domains.base.Domain

property output_metric#

Distance metric on input domain.

Return type

tmlt.core.metrics.Metric

stability_relation(d_in, d_out)#

Returns True only if close inputs produce close outputs.

See the privacy and stability tutorial (add link?) for more information.

Parameters
  • d_in (Any) – Distance between inputs under input_metric.

  • d_out (Any) – Distance between outputs under output_metric.

Return type

bool

__or__(other: Transformation) Transformation#
__or__(other: tmlt.core.measurements.base.Measurement) tmlt.core.measurements.base.Measurement

Return this transformation chained with another component.