Skip to main content

Fourier Accountant for Differential Privacy

Project description

Fourier Accountant

Python code for computing tight DP-guarantees for the subsampled Gaussian mechanism.

The method is described in:

Antti Koskela, Joonas Jälkö, Antti Honkela:
Computing Tight Differential Privacy Guarantees Using FFT
International Conference on Artificial Intelligence and Statistics (2020)

API and Usage

  • get_delta_R(target_eps, sigma, q, ncomp, nx, L) Computes the DP delta for the remove/add neighbouring relation of datasets.
  • get_delta_S(target_eps, sigma, q, ncomp, nx, L) Computes the DP delta for the substitute neighbouring relation of datasets.
  • get_epsilon_R(target_delta, sigma, q, ncomp, nx, L) Computes the DP epsilon for the remove/add neighbouring relation of datasets.
  • get_epsilon_S(target_delta, sigma, q, ncomp, nx, L) Computes the DP epsilon for the substitute neighbouring relation of datasets.

Parameters

  • target_eps (float): Target epsilon to compute delta for
  • target_delta (float): Target delta to compute epsilon for
  • sigma (float or np.ndarray): Privacy noise sigma values
  • q (float or np.ndarray): Subsampling ratios, i.e., how large are batches relative to the dataset
  • ncomp (int or np.ndarray with integer type): Number of compositions, i.e., how many subsequent batch operations are queried
  • nx (int): Number of discretiation points
  • L (float): Limit for the approximation of the privacy loss distribution integral

For parameters sigma, q and ncomp either a single scalar or an array can be passed. If a scalar is passed, the value will be re-interpreted as an array of length 1. Each function then computes the privacy values (delta or epsilon) resulting from a composition of subsampled Gaussian mechanism with following parameters:

  • ncomp[0] times noise level sigma[0] and subsamplign rate q[0]
  • ncomp[1] times noise level sigma[1] and subsamplign rate q[1]
  • etc. for a total of np.sum(ncomp) operations.

An exception is raised if sigma, q and ncomp are found to not be of the same length.

Usage Notes

Note that the functions rely on numerical approximations, which are influenced by choice of parameters nx and L. Increasing L roughly increases the range over which the integral of the privacy loss distribution is approximated. L must be chosen large enough to cover the computed epsilon, otherwise a ValueError is raised (in get_epsilon_*). nx is the number of evaluation points in $[-L,L]$.

Usage Example

import fourier_accountant

ncomp = 1000  # number of compositions of DP queries over minibatches
q     = 0.01  # subsampling ratio of minibatch
sigma = 4.0   # noise level for each query

# computing delta for given epsilon for remove/add neighbouring relation
delta = fourier_accountant.get_delta_R(target_eps=1.0, sigma=sigma, q=q, ncomp=ncomp)
print(delta)
# 4.243484012034273e-06

# computing epsilon for given delta for substitute neighbouring relation
eps = fourier_accountant.get_epsilon_S(target_delta=1e-5, sigma=sigma, q=q, ncomp=ncomp)
print(eps)
# 1.9931200626285734

# computing delta for given epsilon for remove/add neighbouring relation
# with varying parameters
ncomp = np.array([500, 500])
q     = np.array([0.01, 0.01])
sigma = np.array([2.0, 1.0])
delta = fourier_accountant.get_delta_R(target_eps=1.0, sigma=sigma, q=q, ncomp=ncomp)
print(delta)
# 0.0003151995621652058

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

fourier_accountant-0.12.11.tar.gz (11.0 kB view details)

Uploaded Source

Built Distribution

fourier_accountant-0.12.11-py3-none-any.whl (19.3 kB view details)

Uploaded Python 3

File details

Details for the file fourier_accountant-0.12.11.tar.gz.

File metadata

  • Download URL: fourier_accountant-0.12.11.tar.gz
  • Upload date:
  • Size: 11.0 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.2.0 pkginfo/1.5.0.1 requests/2.21.0 setuptools/50.3.2 requests-toolbelt/0.9.1 tqdm/4.32.2 CPython/3.7.6

File hashes

Hashes for fourier_accountant-0.12.11.tar.gz
Algorithm Hash digest
SHA256 c06af809d0b3009c1119634448f41e487e92aeccf4b2f78b4aa13daf5d1dbb5a
MD5 659c597aa0e3713c1d496c4592251357
BLAKE2b-256 fd3d0269e824531be6ddb75e8c70fc9ce631a89039b6f59acba028ff7c5e2031

See more details on using hashes here.

File details

Details for the file fourier_accountant-0.12.11-py3-none-any.whl.

File metadata

  • Download URL: fourier_accountant-0.12.11-py3-none-any.whl
  • Upload date:
  • Size: 19.3 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.2.0 pkginfo/1.5.0.1 requests/2.21.0 setuptools/50.3.2 requests-toolbelt/0.9.1 tqdm/4.32.2 CPython/3.7.6

File hashes

Hashes for fourier_accountant-0.12.11-py3-none-any.whl
Algorithm Hash digest
SHA256 a77b1991db37ef86ffc0dac6dfe0f1e15d1c3881f578c33d6507d41c770e549c
MD5 6d05b8604f4c686966a5945a4467a6c6
BLAKE2b-256 abb5fc80b5e0901ff8aaa8eae7830bc5d922a25c418eb831139591458537542a

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page