privacy_budget#
Classes for specifying privacy budgets.
For a full introduction to privacy budgets, see the privacy budget topic guide.
Classes#
Base class for specifying privacy parameters. |
|
A privacy budget under pure differential privacy. |
|
A privacy budget under approximate differential privacy. |
|
A privacy budget under rho-zero-concentrated differential privacy. |
- class PrivacyBudget#
Bases:
abc.ABC
Base class for specifying privacy parameters.
A PrivacyBudget is a privacy definition, along with its associated parameters. The choice of a PrivacyBudget has an impact on the accuracy of query results. Smaller parameters correspond to a stronger privacy guarantee, and usually lead to less accurate results.
Note
An “infinite” privacy budget means that the chosen DP algorithm will use parameters that do not guarantee privacy. This is not always exactly equivalent to evaluating the query without applying differential privacy. Please see the individual subclasses of PrivacyBudget for details on how to appropriately specify infinite budgets.
- property value: tmlt.core.utils.exact_number.ExactNumber | Tuple[tmlt.core.utils.exact_number.ExactNumber, tmlt.core.utils.exact_number.ExactNumber]#
- Abstractmethod:
- Return type:
Union[tmlt.core.utils.exact_number.ExactNumber, Tuple[tmlt.core.utils.exact_number.ExactNumber, tmlt.core.utils.exact_number.ExactNumber]]
Return the value of the privacy budget.
- property is_infinite: bool#
- Abstractmethod:
- Return type:
Returns true if the privacy budget is infinite.
- abstract __truediv__(other)#
Budgets can be divided by finite integer/float values > 0.
- Return type:
- abstract __mul__(other)#
Budgets can be multiplied by finite integer/float values >= 0.
- Return type:
- abstract __add__(other)#
Budgets can be added to other budgets of compatible types.
Addition is only supported so long as the result is still a valid budget (i.e. all parameters fall within valid ranges).
- Return type:
- abstract __sub__(other)#
Budgets can be subtracted from other budgets of compatible types.
Subtraction is only supported so long as the result is still a valid budget (i.e. all parameters fall within valid ranges).
Subtracting anything from an infinite budget will return an infinite budget.
- Return type:
- classmethod inf()#
- Abstractmethod:
- Return type:
Get an infinite budget of this type.
- class PureDPBudget(epsilon)#
Bases:
PrivacyBudget
A privacy budget under pure differential privacy.
This privacy definition is also known as epsilon-differential privacy, and the associated value is the epsilon privacy parameter. The privacy definition can be found here.
- property value: tmlt.core.utils.exact_number.ExactNumber#
Return the value of the privacy budget as an ExactNumber.
For printing purposes, you should use the epsilon property instead, as it will represent the same value, but be more human readable.
- Return type:
tmlt.core.utils.exact_number.ExactNumber
- property epsilon: int | float#
Returns the value of epsilon as an int or float.
This is helpful for human readability. If you need to use the epsilon value in a computation, you should use self.value instead.
- __init__(epsilon)#
Construct a new PureDPBudget.
- __truediv__(other)#
Divide this budget by a finite integer/float value > 0.
- Return type:
- __mul__(other)#
Multiply this budget by a finite integer/float value >= 0.
- Return type:
- __add__(other)#
Add this budget to another PureDPBudget or an ApproxDPBudget.
The resulting epsilon must be greater than zero, and the resulting delta (if any) must be in [0, 1].
- Return type:
- __sub__(other)#
Subtract a PureDPBudget from this budget.
The resulting epsilon must greater than zero. Subtracting anything from an infinite budget will return an infinite budget.
Note that you cannot subtract an ApproxDPBudget from a PureDPBudget, though the reverse is allowed.
- Return type:
- classmethod inf()#
Get an infinite budget of this type.
- Return type:
- class ApproxDPBudget(epsilon, delta)#
Bases:
PrivacyBudget
A privacy budget under approximate differential privacy.
This privacy definition is also known as (ε, δ)-differential privacy, and the associated privacy parameters are epsilon and delta. The formal definition can be found here.
- Parameters:
- property value: Tuple[tmlt.core.utils.exact_number.ExactNumber, tmlt.core.utils.exact_number.ExactNumber]#
Returns self._epsilon and self._delta as an ExactNumber tuple.
For printing purposes, you might want to use the epsilon and delta properties instead, as they will represent the same values, but be more human readable.
- Return type:
Tuple[tmlt.core.utils.exact_number.ExactNumber, tmlt.core.utils.exact_number.ExactNumber]
- property epsilon: int | float#
Returns the value of epsilon as an int or float.
This is helpful for human readability. If you need to use the epsilon value in a computation, you should use self.value[0] instead.
- property delta: int | float#
Returns the value of delta as an int or float.
This is helpful for human readability. If you need to use the delta value in a computation, you should use self.value[1] instead.
- __init__(epsilon, delta)#
Construct a new ApproxDPBudget.
- Parameters:
epsilon (
Union
[int
,float
,ExactNumber
]) – The epsilon privacy parameter. Must be non-negative. To specify an infinite budget, set epsilon equal to float(‘inf’).delta (
Union
[int
,float
,ExactNumber
]) – The delta privacy parameter. Must be between 0 and 1 (inclusive). If delta is 0, this is equivalent to PureDP.
- __eq__(other)#
Returns True if both ApproxDPBudgets are infinite or have equal values.
- Return type:
- __truediv__(other)#
Divide this budget by a finite integer/float value > 0.
- Return type:
- __mul__(other)#
Multiply this budget by a finite integer/float value >= 0.
- Return type:
- __add__(other)#
Add this budget to another ApproxDPBudget or a PureDPBudget.
The resulting epsilon must greater than zero. If the resulting delta is >1 it will be rounded down to 1.
Addition is performed using basic composition, and the sum is therefore a (possibly loose) upper bound on the privacy loss from running two queries.
- Return type:
- __sub__(other)#
Subtract a PureDPBudget or ApproxDPBudget from this budget.
The resulting epsilon greater than zero, and the resulting delta must be in [0, 1]. Subtracting anything from an infinite budget will return an infinite budget.
Note that you can subtract a PureDPBudget from an ApproxDPBudget, though the reverse is not allowed.
- Return type:
- classmethod inf()#
Get an infinite budget of this type.
- Return type:
- class RhoZCDPBudget(rho)#
Bases:
PrivacyBudget
A privacy budget under rho-zero-concentrated differential privacy.
The definition of rho-zCDP can be found in this paper under Definition 1.1.
- property value: tmlt.core.utils.exact_number.ExactNumber#
Return the value of the privacy budget as an ExactNumber.
For printing purposes, you should use the rho property instead, as it will represent the same value, but be more human readable.
- Return type:
tmlt.core.utils.exact_number.ExactNumber
- property rho: int | float#
Returns the value of rho as an int or float.
This is helpful for human readability. If you need to use the rho value in a computation, you should use self.value instead.
- __init__(rho)#
Construct a new RhoZCDPBudget.
- __truediv__(other)#
Divide this budget by a finite integer/float value > 0.
- Return type:
- __mul__(other)#
Multiply this budget by a finite integer/float value >= 0.
- Return type:
- __add__(other)#
Add this budget to another RhoZCDPBudget.
The resulting rho must be greater than zero.
- Return type:
- __sub__(other)#
Subtract a RhoZCDPBudget from this budget.
The resulting rho must be greater than zero. Subtracting anything from an infinite budget will return an infinite budget.
- Return type:
- classmethod inf()#
Get an infinite budget of this type.
- Return type: