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: 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:

bool

Returns true if the privacy budget is infinite.

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]) –

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.

Return type:

Union[int, float]

property is_infinite: bool#

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

Return type:

bool

__init__(epsilon)#

Construct a new PureDPBudget.

Parameters:

epsilon (Union[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’).

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]) –

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.

Return type:

Union[int, float]

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.

Return type:

Union[int, float]

property is_infinite: bool#

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

Return type:

bool

__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:

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]) –

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.

Return type:

Union[int, float]

property is_infinite: bool#

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

Return type:

bool

__init__(rho)#

Construct a new RhoZCDPBudget.

Parameters:

rho (Union[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’).