pe.dp package

Submodules

pe.dp.dp module

class pe.dp.dp.DP[source]

Bases: ABC

The abstract class for Differential Privacy (DP) histogram mechanism.

abstract add_noise(syn_data)[source]

Add noise to the histogram of synthetic data.

Parameters:

syn_data (pe.data.data.Data) – The synthetic data to add noise

abstract set_epsilon_and_delta(num_iterations, epsilon, delta, noise_multiplier)[source]

Set the epsilon and delta for the DP mechanism. Either epsilon or noise_multiplier should be None.

Parameters:
  • num_iterations (int) – The number of PE iterations

  • epsilon (float or None) – The epsilon value of DP

  • delta (float) – The delta value of DP

  • noise_multiplier (float or None) – The noise multiplier of the DP mechanism

pe.dp.gaussian module

class pe.dp.gaussian.Gaussian[source]

Bases: DP

The Gaussian mechanism for Differential Privacy (DP) histogram.

add_noise(syn_data)[source]

Add noise to the histogram of synthetic data.

Parameters:

syn_data (pe.data.data.Data) – The synthetic data to add noise. The synthetic data should have the pe.constant.data.CLEAN_HISTOGRAM_COLUMN_NAME column

Returns:

The synthetic data with noise added to the histogram. The noisy histogram is stored in the pe.constant.data.DP_HISTOGRAM_COLUMN_NAME column

Return type:

pe.data.data.Data

set_epsilon_and_delta(num_iterations, epsilon, delta, noise_multiplier)[source]

Set the epsilon and delta for the Gaussian mechanism.

Parameters:
  • num_iterations (int) – The number of PE iterations

  • epsilon (float) – The epsilon value of DP

  • delta (float) – The delta value of DP

  • noise_multiplier (float) – The noise multiplier of the DP mechanism

Raises:
  • ValueError – If delta is None

  • ValueError – If both epsilon and noise_multiplier are None or not None

pe.dp.gaussian.compute_epsilon(noise_multiplier, num_steps, delta, max_epsilon=10000000.0)[source]

Compute epsilon of Gaussian mechanism.

Parameters:
  • noise_multiplier (float) – The noise multiplier

  • num_steps (int) – The number of steps

  • delta (float) – The delta value

  • max_epsilon (float, optional) – The maximum epsilon value to search for, defaults to 1e7

Returns:

The epsilon value.

Return type:

float

pe.dp.gaussian.delta_Gaussian(eps, mu)[source]

Compute delta of Gaussian mechanism with shift mu or equivalently noise scale 1/mu.

Parameters:
  • eps (float) – The epsilon value

  • mu (float) – The mu value

Returns:

The delta value

Return type:

float

pe.dp.gaussian.eps_Gaussian(delta, mu, max_epsilon)[source]

Compute eps of Gaussian mechanism with shift mu or equivalently noise scale 1/mu.

Parameters:
  • delta (float) – The delta value

  • mu (float) – The mu value

  • max_epsilon (float) – The maximum epsilon value to search for

pe.dp.gaussian.get_noise_multiplier(epsilon, num_steps, delta, min_noise_multiplier=0.1, max_noise_multiplier=500, max_epsilon=10000000.0)[source]

Get noise multiplier of Gaussian mechanism.

Parameters:
  • epsilon (float) – The epsilon value

  • num_steps (int) – The number of steps

  • delta (float) – The delta value

  • min_noise_multiplier (float, optional) – The minimum noise multiplier to search for, defaults to 1e-1

  • max_noise_multiplier (float, optional) – The maximum noise multiplier to search for, defaults to 500

  • max_epsilon (float, optional) – The maximum epsilon value to search for, defaults to 1e7