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.Measurement
Describes 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]]]) –
- __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
]Sequence
[Measurement
]) – List of measurements to be composed. The provided measurements must all havePureDP
, all haveRhoZCDP
, or all haveApproxDP
as theiroutput_measure
.hint ((
Any
,Any
) →Tuple
[Any
, …] |None
Optional
[Callable
[[Any
,Any
],Tuple
[Any
, …]]] (default:None
)) – 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.
- property measurements#
Returns the list of measurements being composed.
- Return type
- 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
- property input_domain#
Return input domain for the measurement.
- Return type
- property input_metric#
Distance metric on input domain.
- Return type
- property output_measure#
Distance measure on output.
- Return type