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.6+. Support for Python 3.5 and below is deprecated.

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.1.0-cp39-cp39-win_amd64.whl (1.8 MB view details)

Uploaded CPython 3.9 Windows x86-64

python_dp-1.1.0-cp39-cp39-manylinux1_x86_64.whl (3.4 MB view details)

Uploaded CPython 3.9

python_dp-1.1.0-cp39-cp39-macosx_10_14_x86_64.whl (3.5 MB view details)

Uploaded CPython 3.9 macOS 10.14+ x86-64

python_dp-1.1.0-cp38-cp38-win_amd64.whl (1.8 MB view details)

Uploaded CPython 3.8 Windows x86-64

python_dp-1.1.0-cp38-cp38-manylinux1_x86_64.whl (3.4 MB view details)

Uploaded CPython 3.8

python_dp-1.1.0-cp38-cp38-macosx_10_14_x86_64.whl (3.5 MB view details)

Uploaded CPython 3.8 macOS 10.14+ x86-64

python_dp-1.1.0-cp37-cp37m-win_amd64.whl (1.8 MB view details)

Uploaded CPython 3.7m Windows x86-64

python_dp-1.1.0-cp37-cp37m-manylinux1_x86_64.whl (3.3 MB view details)

Uploaded CPython 3.7m

python_dp-1.1.0-cp37-cp37m-macosx_10_14_x86_64.whl (3.5 MB view details)

Uploaded CPython 3.7m macOS 10.14+ x86-64

python_dp-1.1.0-cp36-cp36m-win_amd64.whl (1.8 MB view details)

Uploaded CPython 3.6m Windows x86-64

python_dp-1.1.0-cp36-cp36m-manylinux1_x86_64.whl (3.3 MB view details)

Uploaded CPython 3.6m

python_dp-1.1.0-cp36-cp36m-macosx_10_14_x86_64.whl (3.5 MB view details)

Uploaded CPython 3.6m macOS 10.14+ x86-64

File details

Details for the file python_dp-1.1.0-cp39-cp39-win_amd64.whl.

File metadata

  • Download URL: python_dp-1.1.0-cp39-cp39-win_amd64.whl
  • Upload date:
  • Size: 1.8 MB
  • Tags: CPython 3.9, Windows x86-64
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.4.1 importlib_metadata/4.0.1 pkginfo/1.7.0 requests/2.25.1 requests-toolbelt/0.9.1 tqdm/4.60.0 CPython/3.9.5

File hashes

Hashes for python_dp-1.1.0-cp39-cp39-win_amd64.whl
Algorithm Hash digest
SHA256 36a5671801554153a693445278bbbdc705200c8d545e3fa94f5ad0e8e4a42f1a
MD5 80ae91a59511c74feb893590f7c1534e
BLAKE2b-256 00756152b0c62ea950a150184c65dffc0653d937e999ef1f32e9158fb22e2408

See more details on using hashes here.

File details

Details for the file python_dp-1.1.0-cp39-cp39-manylinux1_x86_64.whl.

File metadata

  • Download URL: python_dp-1.1.0-cp39-cp39-manylinux1_x86_64.whl
  • Upload date:
  • Size: 3.4 MB
  • Tags: CPython 3.9
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.4.1 importlib_metadata/4.0.1 pkginfo/1.7.0 requests/2.25.1 requests-toolbelt/0.9.1 tqdm/4.60.0 CPython/3.9.5

File hashes

Hashes for python_dp-1.1.0-cp39-cp39-manylinux1_x86_64.whl
Algorithm Hash digest
SHA256 4aa62ebf5cfa6f1ae005a78ef48ad17c11388a857f705c34b3f8e887498f24c6
MD5 0ab97b1b93104b27fb0df3647e9a7081
BLAKE2b-256 fc3cbb10a8fb4efda461b676063a2e68958cdd5fd3fb804f8fc5cc4ee2509724

See more details on using hashes here.

File details

Details for the file python_dp-1.1.0-cp39-cp39-macosx_10_14_x86_64.whl.

File metadata

  • Download URL: python_dp-1.1.0-cp39-cp39-macosx_10_14_x86_64.whl
  • Upload date:
  • Size: 3.5 MB
  • Tags: CPython 3.9, macOS 10.14+ x86-64
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.4.1 importlib_metadata/4.0.1 pkginfo/1.7.0 requests/2.25.1 requests-toolbelt/0.9.1 tqdm/4.60.0 CPython/3.9.5

File hashes

Hashes for python_dp-1.1.0-cp39-cp39-macosx_10_14_x86_64.whl
Algorithm Hash digest
SHA256 9c807f4bad7ef4f462b72d51dd44cf9c8d690438b38d86d25fa074feb9496b93
MD5 2b6e62ab978e59ac86d8aa0f5bbc93f7
BLAKE2b-256 90730e9d9c1297b5c5efe4e7d66a2888ac797812cc6b7a4c004249e8bbcdbd91

See more details on using hashes here.

File details

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

File metadata

  • Download URL: python_dp-1.1.0-cp38-cp38-win_amd64.whl
  • Upload date:
  • Size: 1.8 MB
  • Tags: CPython 3.8, Windows x86-64
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.4.1 importlib_metadata/4.0.1 pkginfo/1.7.0 requests/2.25.1 requests-toolbelt/0.9.1 tqdm/4.60.0 CPython/3.8.10

File hashes

Hashes for python_dp-1.1.0-cp38-cp38-win_amd64.whl
Algorithm Hash digest
SHA256 e51bee300e4b8783289756914f52e2dd6b935ac0c4cf6582a3105c805e5a05c7
MD5 96b11a1bf456139d577bcea6347da674
BLAKE2b-256 e6544a6f5a8280883461d382e4d1b542b2fa2ea877af80cf823fc9ccd64bc3e4

See more details on using hashes here.

File details

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

File metadata

  • Download URL: python_dp-1.1.0-cp38-cp38-manylinux1_x86_64.whl
  • Upload date:
  • Size: 3.4 MB
  • Tags: CPython 3.8
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.4.1 importlib_metadata/4.0.1 pkginfo/1.7.0 requests/2.25.1 requests-toolbelt/0.9.1 tqdm/4.60.0 CPython/3.8.10

File hashes

Hashes for python_dp-1.1.0-cp38-cp38-manylinux1_x86_64.whl
Algorithm Hash digest
SHA256 6563386e15391fad9ea778713d6e323195374a5f1167f57f912a48923ed0ade3
MD5 e71a4e29de5357c947c3b60f3f19bbc3
BLAKE2b-256 ff6ec5ee2a9428558c441ea03238889cc1f6981f461e3de6122ad4b71efd7826

See more details on using hashes here.

File details

Details for the file python_dp-1.1.0-cp38-cp38-macosx_10_14_x86_64.whl.

File metadata

  • Download URL: python_dp-1.1.0-cp38-cp38-macosx_10_14_x86_64.whl
  • Upload date:
  • Size: 3.5 MB
  • Tags: CPython 3.8, macOS 10.14+ x86-64
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.4.1 importlib_metadata/4.0.1 pkginfo/1.7.0 requests/2.25.1 requests-toolbelt/0.9.1 tqdm/4.60.0 CPython/3.8.10

File hashes

Hashes for python_dp-1.1.0-cp38-cp38-macosx_10_14_x86_64.whl
Algorithm Hash digest
SHA256 e021dac117be8a12adeb73aa0061b24df9d0e43010a3e6e5ca304f795c5d87aa
MD5 c71482c24cbc82565829168898b54f74
BLAKE2b-256 87ca0e1ca8caa520eb1b851de60e26f763be755a5d666cd431af5860b62007ed

See more details on using hashes here.

File details

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

File metadata

  • Download URL: python_dp-1.1.0-cp37-cp37m-win_amd64.whl
  • Upload date:
  • Size: 1.8 MB
  • Tags: CPython 3.7m, Windows x86-64
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.4.1 importlib_metadata/4.0.1 pkginfo/1.7.0 requests/2.25.1 requests-toolbelt/0.9.1 tqdm/4.60.0 CPython/3.7.9

File hashes

Hashes for python_dp-1.1.0-cp37-cp37m-win_amd64.whl
Algorithm Hash digest
SHA256 71bd89a80447e9638f83b7b598a392bcf50dc10dce93210a6fbc607931c7ee78
MD5 65573fce3e2031a90aef5d419f44f8b1
BLAKE2b-256 e2c0db3d3a680de0db1b0d1ea742ba80c5ce7ca477aeaf580107436521989162

See more details on using hashes here.

File details

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

File metadata

  • Download URL: python_dp-1.1.0-cp37-cp37m-manylinux1_x86_64.whl
  • Upload date:
  • Size: 3.3 MB
  • Tags: CPython 3.7m
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.4.1 importlib_metadata/4.0.1 pkginfo/1.7.0 requests/2.25.1 requests-toolbelt/0.9.1 tqdm/4.60.0 CPython/3.7.10

File hashes

Hashes for python_dp-1.1.0-cp37-cp37m-manylinux1_x86_64.whl
Algorithm Hash digest
SHA256 309acc396cf0e68e5995f333560a6b173710cec69ecaeccf11f0606759ef60d4
MD5 7fa1dafa127effa16efda0726dd3e154
BLAKE2b-256 7fb576b36fab1cb732a25c9c6406822af4d500cdfa6b3bd40a268315d2bdb2c6

See more details on using hashes here.

File details

Details for the file python_dp-1.1.0-cp37-cp37m-macosx_10_14_x86_64.whl.

File metadata

  • Download URL: python_dp-1.1.0-cp37-cp37m-macosx_10_14_x86_64.whl
  • Upload date:
  • Size: 3.5 MB
  • Tags: CPython 3.7m, macOS 10.14+ x86-64
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.4.1 importlib_metadata/4.0.1 pkginfo/1.7.0 requests/2.25.1 requests-toolbelt/0.9.1 tqdm/4.60.0 CPython/3.7.10

File hashes

Hashes for python_dp-1.1.0-cp37-cp37m-macosx_10_14_x86_64.whl
Algorithm Hash digest
SHA256 ab490def76bb203b93d9ea3426ea3175dc92659118da9f1213c50c5d1774ad4c
MD5 84c14ceda029e28630744b9315c3711c
BLAKE2b-256 7cc3db1114cba3b7cae58a7642fcb3b876c244ce3924ad04edbe657ee6c5fd9e

See more details on using hashes here.

File details

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

File metadata

  • Download URL: python_dp-1.1.0-cp36-cp36m-win_amd64.whl
  • Upload date:
  • Size: 1.8 MB
  • Tags: CPython 3.6m, Windows x86-64
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.4.1 importlib_metadata/4.0.1 pkginfo/1.7.0 requests/2.25.1 requests-toolbelt/0.9.1 tqdm/4.60.0 CPython/3.6.8

File hashes

Hashes for python_dp-1.1.0-cp36-cp36m-win_amd64.whl
Algorithm Hash digest
SHA256 33bb10f5ca9b2cc3ec02727cad32685665c6c06ce5e47f4c1c11dd6aa987e999
MD5 25adf34da89a1769e2960c712c78cd20
BLAKE2b-256 450d96145f951c04a10616ccfcc1987e79102260a62845ab5a33e6366d767e95

See more details on using hashes here.

File details

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

File metadata

  • Download URL: python_dp-1.1.0-cp36-cp36m-manylinux1_x86_64.whl
  • Upload date:
  • Size: 3.3 MB
  • Tags: CPython 3.6m
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.4.1 importlib_metadata/4.0.1 pkginfo/1.7.0 requests/2.25.1 requests-toolbelt/0.9.1 tqdm/4.60.0 CPython/3.6.13

File hashes

Hashes for python_dp-1.1.0-cp36-cp36m-manylinux1_x86_64.whl
Algorithm Hash digest
SHA256 d94ccf53e146eb6cb1865d4dc652500ed8c541f676e82e291ef158424e7e2429
MD5 2b202fe45356b776f8fd9432c3f2e14b
BLAKE2b-256 74520e307ec024b31c666b8fc9383d8a8a14c2cee65aba3ee9ab53a44776d9f1

See more details on using hashes here.

File details

Details for the file python_dp-1.1.0-cp36-cp36m-macosx_10_14_x86_64.whl.

File metadata

  • Download URL: python_dp-1.1.0-cp36-cp36m-macosx_10_14_x86_64.whl
  • Upload date:
  • Size: 3.5 MB
  • Tags: CPython 3.6m, macOS 10.14+ x86-64
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.4.1 importlib_metadata/4.0.1 pkginfo/1.7.0 requests/2.25.1 requests-toolbelt/0.9.1 tqdm/4.60.0 CPython/3.6.13

File hashes

Hashes for python_dp-1.1.0-cp36-cp36m-macosx_10_14_x86_64.whl
Algorithm Hash digest
SHA256 b30f9c783dc81804d854c18686e1dd9e6f49119515f7fea42c42455de1bb457f
MD5 6557aed4838e9300e75b6486edb04932
BLAKE2b-256 2a7d90e1b3b87ce31fbdba655896855781cf6fc9fb5cea31a4b822ba63c685e8

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