composition#
Measurement for combining multiple measurements into a single measurement.
Classes#
Describes a measurement constructed by composing two or more Measurements. |
- class Composition(measurements, hint=None)#
Bases:
tmlt.core.measurements.base.MeasurementDescribes a measurement constructed by composing two or more Measurements.
- Parameters:
measurements (Sequence[tmlt.core.measurements.base.Measurement]) –
hint (Optional[Callable[[Any, Any], Tuple[Any, Ellipsis]]]) –
- property measurements: List[tmlt.core.measurements.base.Measurement]#
Returns the list of measurements being composed.
- Return type:
- property input_domain: tmlt.core.domains.base.Domain#
Return input domain for the measurement.
- Return type:
- property input_metric: tmlt.core.metrics.Metric#
Distance metric on input domain.
- Return type:
- property output_measure: tmlt.core.measures.Measure#
Distance measure on output.
- Return type:
- __init__(measurements, hint=None)#
Constructor.
It supports PureDP, ApproxDP, and RhoZCDP. Input metrics, domains, and output measures must be identical across all supplied measurements.
- Parameters:
measurements (
Sequence[Measurement]) – List of measurements to be composed. The provided measurements must all havePureDP, all haveRhoZCDP, or all haveApproxDPas theiroutput_measure.hint (
Optional[Callable[[Any,Any],Tuple[Any,...]]]) – An optional hint. A hint is only required if one or more of the measurements’privacy_function()’s raiseNotImplementedError. The hint takes in the same arguments asprivacy_relation(), and should return a d_out for each measurement to be composed, where all of the d_outs sum to less than the d_out passed into the hint.
- privacy_function(d_in)#
Returns the smallest d_out satisfied by the measurement.
Returns the sum of the
privacy_function()’s of the composed measurements on d_in (adding element-wise forApproxDP).- Parameters:
d_in (Any) – Distance between inputs under input_metric.
- Raises:
NotImplementedError – If the
privacy_function()of one of the composed measurements raisesNotImplementedError.- Return type:
Any
- privacy_relation(d_in, d_out)#
Returns True only if outputs are close under close inputs.
Let d_outs be the d_out from the
privacy_function()’s of all measurements or the d_outs from the hint if one of them raisesNotImplementedError.And total_d_out to be the sum of d_outs (adding element-wise for
ApproxDP).This returns True if total_d_out <= d_out (the input argument) and each composed measurement satisfies its
privacy_relation()from d_in to its d_out from d_outs.- Parameters:
d_in (Any) – Distance between inputs under input_metric.
d_out (Any) – Distance between outputs under output_measure.
- Raises:
ValueError – If a hint is not provided and the
privacy_function()of one of the composed measurements raisesNotImplementedError.- Return type:
- __call__(data)#
Return answers to composed measurements.
- Parameters:
data (Any) –
- Return type:
List