Skip to main content

Python API for Google's Differential Privacy library

Project description

Tests Version License

Introduction to PyDP

In today’s data-driven world, more and more researchers and data scientists use machine learning to create better models or more innovative solutions for a better future.

These models often tend to handle sensitive or personal data, which can cause privacy issues. For example, some AI models can memorize details about the data they’ve been trained on and could potentially leak these details later on.

To help measure sensitive data leakage and reduce the possibility of it happening, there is a mathematical framework called differential privacy.

In 2020, OpenMined created a Python wrapper for Google’s Differential Privacy project called PyDP. The library provides a set of ε-differentially private algorithms, which can be used to produce aggregate statistics over numeric data sets containing private or sensitive information. Therefore, with PyDP you can control the privacy guarantee and accuracy of your model written in Python.

Things to remember about PyDP:

  • ::rocket: Features differentially private algorithms including: BoundedMean, BoundedSum, Max, Count Above, Percentile, Min, Median, etc.

  • All the computation methods mentioned above use Laplace noise only (other noise mechanisms will be added soon! :smiley:).

  • ::fire: Currently supports Linux and macOS (Windows support coming soon :smiley:)

  • ::star: Use Python 3.x.

Installation

To install PyDP, use the PiPy package manager:

pip install python-dp

(If you have pip3 separately for Python 3.x, use pip3 install python-dp.)

Examples

Refer to the curated list of tutorials and sample code to learn more about the PyDP library.

You can also get started with an introduction to PyDP (a Jupyter notebook) and the carrots demo (a Python file).

Example: calculate the Bounded Mean

# Import PyDP
import pydp as dp
# Import the Bounded Mean algorithm
from pydp.algorithms.laplacian import BoundedMean

# Calculate the Bounded Mean
# Structure: `BoundedMean(epsilon: double, lower: int, upper: int)`
# `epsilon`: a Double, between 0 and 1, denoting the privacy threshold,
#            measures the acceptable loss of privacy (with 0 meaning no loss is acceptable)
# `lower` and `upper`: Integers, representing lower and upper bounds, respectively
x = BoundedMean(0.6, 1, 10)

# If the lower and upper bounds are not specified,
# PyDP automatically calculates these bounds
# x = BoundedMean(epsilon: double)
x = BoundedMean(0.6)

# Calculate the result
# Currently supported data types are integers and floats
# Future versions will support additional data types
# (Refer to https://github.com/OpenMined/PyDP/blob/dev/examples/carrots.py)
x.quick_result(input_data: list)

Learning Resources

Go to resources to learn more about differential privacy.

Support and Community on Slack

If you have questions about the PyDP library, join OpenMined’s Slack and check the #lib_pydp channel. To follow the code source changes, join #code_dp_python.

Contributing

To contribute to the PyDP project, read the guidelines.

Pull requests are welcome. If you want to introduce major changes, please open an issue first to discuss what you would like to change.

Please make sure to update tests as appropriate.

<!– ## Contributors –>

License

Apache License 2.0

Project details


Download files

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

Source Distributions

No source distribution files available for this release.See tutorial on generating distribution archives.

Built Distributions

python_dp-1.0.0-cp38-cp38-win_amd64.whl (1.6 MB view details)

Uploaded CPython 3.8 Windows x86-64

python_dp-1.0.0-cp38-cp38-manylinux1_x86_64.whl (3.0 MB view details)

Uploaded CPython 3.8

python_dp-1.0.0-cp38-cp38-macosx_10_15_x86_64.whl (3.1 MB view details)

Uploaded CPython 3.8 macOS 10.15+ x86-64

python_dp-1.0.0-cp37-cp37m-win_amd64.whl (1.6 MB view details)

Uploaded CPython 3.7m Windows x86-64

python_dp-1.0.0-cp37-cp37m-manylinux1_x86_64.whl (3.0 MB view details)

Uploaded CPython 3.7m

python_dp-1.0.0-cp37-cp37m-macosx_10_15_x86_64.whl (3.1 MB view details)

Uploaded CPython 3.7m macOS 10.15+ x86-64

python_dp-1.0.0-cp36-cp36m-win_amd64.whl (1.6 MB view details)

Uploaded CPython 3.6m Windows x86-64

python_dp-1.0.0-cp36-cp36m-manylinux1_x86_64.whl (3.0 MB view details)

Uploaded CPython 3.6m

python_dp-1.0.0-cp36-cp36m-macosx_10_15_x86_64.whl (3.1 MB view details)

Uploaded CPython 3.6m macOS 10.15+ x86-64

python_dp-1.0.0-cp35-cp35m-win_amd64.whl (1.6 MB view details)

Uploaded CPython 3.5m Windows x86-64

python_dp-1.0.0-cp35-cp35m-manylinux1_x86_64.whl (3.0 MB view details)

Uploaded CPython 3.5m

python_dp-1.0.0-cp35-cp35m-macosx_10_15_x86_64.whl (3.1 MB view details)

Uploaded CPython 3.5m macOS 10.15+ x86-64

File details

Details for the file python_dp-1.0.0-cp38-cp38-win_amd64.whl.

File metadata

  • Download URL: python_dp-1.0.0-cp38-cp38-win_amd64.whl
  • Upload date:
  • Size: 1.6 MB
  • Tags: CPython 3.8, Windows x86-64
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.2.0 pkginfo/1.5.0.1 requests/2.24.0 setuptools/47.1.0 requests-toolbelt/0.9.1 tqdm/4.48.2 CPython/3.8.5

File hashes

Hashes for python_dp-1.0.0-cp38-cp38-win_amd64.whl
Algorithm Hash digest
SHA256 c3fc0b13a7200540158b122109dc56edc4166822f14b9c5c3d32e36fc14b71b4
MD5 494d7decfde77e800133096415d49534
BLAKE2b-256 0c3d44c8efe474d5f284acd70bcaed4d8ba9adca7880ef2f73d461cff339756f

See more details on using hashes here.

File details

Details for the file python_dp-1.0.0-cp38-cp38-manylinux1_x86_64.whl.

File metadata

  • Download URL: python_dp-1.0.0-cp38-cp38-manylinux1_x86_64.whl
  • Upload date:
  • Size: 3.0 MB
  • Tags: CPython 3.8
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.2.0 pkginfo/1.5.0.1 requests/2.24.0 setuptools/47.1.0 requests-toolbelt/0.9.1 tqdm/4.48.2 CPython/3.8.5

File hashes

Hashes for python_dp-1.0.0-cp38-cp38-manylinux1_x86_64.whl
Algorithm Hash digest
SHA256 4610bcab3f59275bf932bebf874630cc0b872d34f8c821a68a10ec0c81b4e7ec
MD5 1b93f2b6b01838a292ed8f3eee156afc
BLAKE2b-256 ea777e4c3715eb65a38d238fd6203dfdf52271caee5e719403b45526b093085b

See more details on using hashes here.

File details

Details for the file python_dp-1.0.0-cp38-cp38-macosx_10_15_x86_64.whl.

File metadata

  • Download URL: python_dp-1.0.0-cp38-cp38-macosx_10_15_x86_64.whl
  • Upload date:
  • Size: 3.1 MB
  • Tags: CPython 3.8, macOS 10.15+ x86-64
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.2.0 pkginfo/1.5.0.1 requests/2.24.0 setuptools/47.1.0 requests-toolbelt/0.9.1 tqdm/4.48.2 CPython/3.8.5

File hashes

Hashes for python_dp-1.0.0-cp38-cp38-macosx_10_15_x86_64.whl
Algorithm Hash digest
SHA256 a84405e2871d37e166c42ebd3f622a6b64a38edc06aab4fa080517293ad02210
MD5 3bc9388b7e7661d1fbb5200e2ee7976e
BLAKE2b-256 66252c8eb9a059bf59695b77689b846183366031e281cc9524087e094a36427a

See more details on using hashes here.

File details

Details for the file python_dp-1.0.0-cp37-cp37m-win_amd64.whl.

File metadata

  • Download URL: python_dp-1.0.0-cp37-cp37m-win_amd64.whl
  • Upload date:
  • Size: 1.6 MB
  • Tags: CPython 3.7m, Windows x86-64
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.2.0 pkginfo/1.5.0.1 requests/2.24.0 setuptools/47.1.0 requests-toolbelt/0.9.1 tqdm/4.48.2 CPython/3.7.9

File hashes

Hashes for python_dp-1.0.0-cp37-cp37m-win_amd64.whl
Algorithm Hash digest
SHA256 c12d54fb5a5014c0dda205fc627cf24617d8f533805d098a36d0ffa49ab6e019
MD5 dc777361c7bae915aca9166ce5dd003f
BLAKE2b-256 f5b8164b6edc237543d232688092a9938a747a6a9b6ae9777289f8a797a2b067

See more details on using hashes here.

File details

Details for the file python_dp-1.0.0-cp37-cp37m-manylinux1_x86_64.whl.

File metadata

  • Download URL: python_dp-1.0.0-cp37-cp37m-manylinux1_x86_64.whl
  • Upload date:
  • Size: 3.0 MB
  • Tags: CPython 3.7m
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.2.0 pkginfo/1.5.0.1 requests/2.24.0 setuptools/47.1.0 requests-toolbelt/0.9.1 tqdm/4.48.2 CPython/3.7.9

File hashes

Hashes for python_dp-1.0.0-cp37-cp37m-manylinux1_x86_64.whl
Algorithm Hash digest
SHA256 74b9b3737a205b0955cc0c6bb1dc49658d63b617077b1560ddcb9c28d173efac
MD5 d04ccb91f419a31e9457ce8b7907abf4
BLAKE2b-256 18c90c5443c74bc3a1dfae99e6ac3522088021db347b3df305dc5fc09650b9bd

See more details on using hashes here.

File details

Details for the file python_dp-1.0.0-cp37-cp37m-macosx_10_15_x86_64.whl.

File metadata

  • Download URL: python_dp-1.0.0-cp37-cp37m-macosx_10_15_x86_64.whl
  • Upload date:
  • Size: 3.1 MB
  • Tags: CPython 3.7m, macOS 10.15+ x86-64
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.2.0 pkginfo/1.5.0.1 requests/2.24.0 setuptools/47.1.0 requests-toolbelt/0.9.1 tqdm/4.48.2 CPython/3.7.9

File hashes

Hashes for python_dp-1.0.0-cp37-cp37m-macosx_10_15_x86_64.whl
Algorithm Hash digest
SHA256 88c70ab3c6e9a952288a3d47741277909211d19b8db1f873bfbf9c3f3f9fb488
MD5 f6d7d758d49185b810f7d932e24c17d0
BLAKE2b-256 faf6f5eee6d2189724277747ab0800978a92f81c945b187a6c5e5acdb939612c

See more details on using hashes here.

File details

Details for the file python_dp-1.0.0-cp36-cp36m-win_amd64.whl.

File metadata

  • Download URL: python_dp-1.0.0-cp36-cp36m-win_amd64.whl
  • Upload date:
  • Size: 1.6 MB
  • Tags: CPython 3.6m, Windows x86-64
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.2.0 pkginfo/1.5.0.1 requests/2.24.0 setuptools/40.6.2 requests-toolbelt/0.9.1 tqdm/4.48.2 CPython/3.6.8

File hashes

Hashes for python_dp-1.0.0-cp36-cp36m-win_amd64.whl
Algorithm Hash digest
SHA256 a4d40d93cb1f88926df6286340f724291a19f3e8905a790180f57f6edc18c278
MD5 b6056f63fb3a2f69e02415146b12b200
BLAKE2b-256 2b28da1026732cd4c98e2c686ccc1894e28481b83a35e57e85a1d6b6d7dca9c0

See more details on using hashes here.

File details

Details for the file python_dp-1.0.0-cp36-cp36m-manylinux1_x86_64.whl.

File metadata

  • Download URL: python_dp-1.0.0-cp36-cp36m-manylinux1_x86_64.whl
  • Upload date:
  • Size: 3.0 MB
  • Tags: CPython 3.6m
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.2.0 pkginfo/1.5.0.1 requests/2.24.0 setuptools/40.6.2 requests-toolbelt/0.9.1 tqdm/4.48.2 CPython/3.6.12

File hashes

Hashes for python_dp-1.0.0-cp36-cp36m-manylinux1_x86_64.whl
Algorithm Hash digest
SHA256 8de68bb010b6404d78375ad5432c51eced2fb428441f9a319fc4a9c188ba6280
MD5 5fbbe7654884f188832c85e00ae9507a
BLAKE2b-256 5ca111430895704b0017c0dd9e86cb820d2afcd0c244c7d9ad2f5eba9fa1aeac

See more details on using hashes here.

File details

Details for the file python_dp-1.0.0-cp36-cp36m-macosx_10_15_x86_64.whl.

File metadata

  • Download URL: python_dp-1.0.0-cp36-cp36m-macosx_10_15_x86_64.whl
  • Upload date:
  • Size: 3.1 MB
  • Tags: CPython 3.6m, macOS 10.15+ x86-64
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.2.0 pkginfo/1.5.0.1 requests/2.24.0 setuptools/40.6.2 requests-toolbelt/0.9.1 tqdm/4.48.2 CPython/3.6.12

File hashes

Hashes for python_dp-1.0.0-cp36-cp36m-macosx_10_15_x86_64.whl
Algorithm Hash digest
SHA256 3c3e8cbed8ab3495cea2d212793af91df479af9c2a58f0e7926d199af51586f5
MD5 d4ff01ecde12d59a58261e13ea8f92d2
BLAKE2b-256 342f23dda827dd24b1a024f548c6270cc4f28aade4849a51244668a187bbb0ad

See more details on using hashes here.

File details

Details for the file python_dp-1.0.0-cp35-cp35m-win_amd64.whl.

File metadata

  • Download URL: python_dp-1.0.0-cp35-cp35m-win_amd64.whl
  • Upload date:
  • Size: 1.6 MB
  • Tags: CPython 3.5m, Windows x86-64
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/1.15.0 pkginfo/1.5.0.1 requests/2.24.0 setuptools/28.8.0 requests-toolbelt/0.9.1 tqdm/4.48.2 CPython/3.5.4

File hashes

Hashes for python_dp-1.0.0-cp35-cp35m-win_amd64.whl
Algorithm Hash digest
SHA256 be46aa088421564242c92c8b12e4a2bfa63e3fa5e902257c5afe211768087879
MD5 6be9edb13d6770943b8084e30cc4b307
BLAKE2b-256 51c39a2bc38ca77c215f5ed8565bbfa676b8483d52fe4f54081094047bef1acb

See more details on using hashes here.

File details

Details for the file python_dp-1.0.0-cp35-cp35m-manylinux1_x86_64.whl.

File metadata

  • Download URL: python_dp-1.0.0-cp35-cp35m-manylinux1_x86_64.whl
  • Upload date:
  • Size: 3.0 MB
  • Tags: CPython 3.5m
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/1.15.0 pkginfo/1.5.0.1 requests/2.24.0 setuptools/28.8.0 requests-toolbelt/0.9.1 tqdm/4.48.2 CPython/3.5.9

File hashes

Hashes for python_dp-1.0.0-cp35-cp35m-manylinux1_x86_64.whl
Algorithm Hash digest
SHA256 532c58638d30e25fb90eeea526ff2c52b1f9dbce42cae0d2d1524b3b37da956c
MD5 a1999d4f414df6311ac501f65c2c3aed
BLAKE2b-256 45bd2f598f550eb76321785dd335cb504696144512591a308b41753f0111e4ae

See more details on using hashes here.

File details

Details for the file python_dp-1.0.0-cp35-cp35m-macosx_10_15_x86_64.whl.

File metadata

  • Download URL: python_dp-1.0.0-cp35-cp35m-macosx_10_15_x86_64.whl
  • Upload date:
  • Size: 3.1 MB
  • Tags: CPython 3.5m, macOS 10.15+ x86-64
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/1.15.0 pkginfo/1.5.0.1 requests/2.24.0 setuptools/28.8.0 requests-toolbelt/0.9.1 tqdm/4.48.2 CPython/3.5.9

File hashes

Hashes for python_dp-1.0.0-cp35-cp35m-macosx_10_15_x86_64.whl
Algorithm Hash digest
SHA256 b1e52b4a3bbef090445433ee59e3f9475e763398548010caa14e124530dbcf3c
MD5 c51da3dd92179220e621c9804ca5c733
BLAKE2b-256 c8662b7e2c76460c423457df9030a3f4b6c476549aa8f8e061a9d86b31c5e6ec

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