privacy_budget#

Classes for specifying privacy budgets.

For a full introduction to privacy budgets, see the privacy budget topic guide.

Classes#

PrivacyBudget

Base class for specifying privacy parameters.

PureDPBudget

A privacy budget under pure differential privacy.

ApproxDPBudget

A privacy budget under approximate differential privacy.

RhoZCDPBudget

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#

Return the value of the privacy budget.

Return type

Union[tmlt.core.utils.exact_number.ExactNumber, Tuple[tmlt.core.utils.exact_number.ExactNumber, tmlt.core.utils.exact_number.ExactNumber]]

property is_infinite#

Returns true if the privacy budget is infinite.

Return type

bool

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.

Parameters

epsilon (Union[int, float, tmlt.core.utils.exact_number.ExactNumber]) –

__init__(epsilon)#

Construct a new PureDPBudget.

Parameters

epsilon (int | float | ExactNumberUnion[int, float, ExactNumber]) – The epsilon privacy parameter. Must be non-negative and cannot be NaN. To specify an infinite budget, set epsilon equal to float(‘inf’).

property value#

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#

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.

Return type

Union[int, float]

property is_infinite#

Returns true if epsilon is float(‘inf’).

Return type

bool

__eq__(other)#

Returns whether or not a PureDPBudget is equivalent to another PrivacyBudget.

PureDPBudgets are considered equal to ApproxDPBudgets that have delta of 0 and the same epsilon.

Return type

bool

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
  • epsilon (Union[int, float, tmlt.core.utils.exact_number.ExactNumber]) –

  • delta (Union[int, float, tmlt.core.utils.exact_number.ExactNumber]) –

__init__(epsilon, delta)#

Construct a new ApproxDPBudget.

Parameters
  • epsilon (int | float | ExactNumberUnion[int, float, ExactNumber]) – The epsilon privacy parameter. Must be non-negative. To specify an infinite budget, set epsilon equal to float(‘inf’).

  • delta (int | float | ExactNumberUnion[int, float, ExactNumber]) – The delta privacy parameter. Must be between 0 and 1 (inclusive). If delta is 0, this is equivalent to PureDP.

property value#

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#

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.

Return type

Union[int, float]

property delta#

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.

Return type

Union[int, float]

property is_infinite#

Returns true if epsilon is float(‘inf’) or delta is 1.

Return type

bool

__eq__(other)#

Returns whether an ApproxDPBudget is equivalent to another privacy budget.

ApproxDPBudgets that have delta of 0 are considered equal to PureDPBudgets with the same epsilon. ApproxDPBudgets that provide no privacy guarantee are considered equal (for example, if one has an epsilon of float(‘inf’) and the other has a delta of 1).

Return type

bool

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.

Parameters

rho (Union[int, float, tmlt.core.utils.exact_number.ExactNumber]) –

__init__(rho)#

Construct a new RhoZCDPBudget.

Parameters

rho (int | float | ExactNumberUnion[int, float, ExactNumber]) – The rho privacy parameter. Rho must be non-negative and cannot be NaN. To specify an infinite budget, set rho equal to float(‘inf’).

property value#

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#

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.

Return type

Union[int, float]

property is_infinite#

Returns true if rho is float(‘inf’).

Return type

bool

__eq__(other)#

Returns whether or not two RhoZCDPBudgets are equivalent.

Return type

bool