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.1-cp38-cp38-win_amd64.whl (1.6 MB view details)

Uploaded CPython 3.8 Windows x86-64

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

Uploaded CPython 3.8

python_dp-1.0.1-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.1-cp37-cp37m-win_amd64.whl (1.6 MB view details)

Uploaded CPython 3.7m Windows x86-64

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

Uploaded CPython 3.7m

python_dp-1.0.1-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.1-cp36-cp36m-win_amd64.whl (1.6 MB view details)

Uploaded CPython 3.6m Windows x86-64

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

Uploaded CPython 3.6m

python_dp-1.0.1-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.1-cp35-cp35m-win_amd64.whl (1.6 MB view details)

Uploaded CPython 3.5m Windows x86-64

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

Uploaded CPython 3.5m

python_dp-1.0.1-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.1-cp38-cp38-win_amd64.whl.

File metadata

  • Download URL: python_dp-1.0.1-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/49.2.1 requests-toolbelt/0.9.1 tqdm/4.50.2 CPython/3.8.6

File hashes

Hashes for python_dp-1.0.1-cp38-cp38-win_amd64.whl
Algorithm Hash digest
SHA256 462517a811c0a116566cd050996492c102b302d10e266ef507cdb220e6be751d
MD5 a67a9faf417aeb6612fbfed1686c7748
BLAKE2b-256 8a5a00691518a15a6b85a85488422824674fb9c8544e00a295f6bf0a9320afd1

See more details on using hashes here.

File details

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

File metadata

  • Download URL: python_dp-1.0.1-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/49.2.1 requests-toolbelt/0.9.1 tqdm/4.50.2 CPython/3.8.6

File hashes

Hashes for python_dp-1.0.1-cp38-cp38-manylinux1_x86_64.whl
Algorithm Hash digest
SHA256 d0447f1eb01abaae10affe5d6ac603dc07d40e92094eea1421b78ef390dd98a6
MD5 9956103353fc7c359c845a4dc2a12f89
BLAKE2b-256 604c257cd7fd999830d4a5311b59f71b181510f61b373fc180f0884d45b4a16b

See more details on using hashes here.

File details

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

File metadata

  • Download URL: python_dp-1.0.1-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/49.2.1 requests-toolbelt/0.9.1 tqdm/4.50.2 CPython/3.8.6

File hashes

Hashes for python_dp-1.0.1-cp38-cp38-macosx_10_15_x86_64.whl
Algorithm Hash digest
SHA256 a0456100eadb551f51564794568dcf5b7e0e840bcd636c94cc27978f50017d8a
MD5 138d9ae4471e20d9b330633d77318061
BLAKE2b-256 78f0e8ed8f234a1395bcc75936c4a64a9bd98c27e2c17caa43ba550559d26c6d

See more details on using hashes here.

File details

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

File metadata

  • Download URL: python_dp-1.0.1-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.50.2 CPython/3.7.9

File hashes

Hashes for python_dp-1.0.1-cp37-cp37m-win_amd64.whl
Algorithm Hash digest
SHA256 d582db7b863c342f7fa9b9c8684826efdd267cfc92163259ae5a6bdbf781df4c
MD5 52862cc403c0c58dd6af44bcd758b28e
BLAKE2b-256 ff8711a1c4a87519833d6197ed88ff876d6d10148fdff2e0713705668d2d3f83

See more details on using hashes here.

File details

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

File metadata

  • Download URL: python_dp-1.0.1-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.50.2 CPython/3.7.9

File hashes

Hashes for python_dp-1.0.1-cp37-cp37m-manylinux1_x86_64.whl
Algorithm Hash digest
SHA256 1cd2ad3f24d9d2659f24d6cfa4347919dc24caa002e2eb0f51fd2c97bd505e9d
MD5 b0fe91a79a556b2dae1839abb76ac93e
BLAKE2b-256 08a58fa4f76a4abbf88e038feb5d3350a9586d9563dc37d9e88d64078b551a81

See more details on using hashes here.

File details

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

File metadata

  • Download URL: python_dp-1.0.1-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.50.2 CPython/3.7.9

File hashes

Hashes for python_dp-1.0.1-cp37-cp37m-macosx_10_15_x86_64.whl
Algorithm Hash digest
SHA256 54875c39d8b4b02702f42651ff9315ecae17182cc36f54d07953dd74f7c3ed57
MD5 67d4f714ba4eb23a6d4aa3f6f743b2cb
BLAKE2b-256 f7fd0c690be66a8aa133acfc6001d345e36f8873b42214581f107710ee780c4a

See more details on using hashes here.

File details

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

File metadata

  • Download URL: python_dp-1.0.1-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.50.2 CPython/3.6.8

File hashes

Hashes for python_dp-1.0.1-cp36-cp36m-win_amd64.whl
Algorithm Hash digest
SHA256 f9e8d57a2ab7a81e082db712b86d04b4e0c8cb8af724594e14a180cf24390025
MD5 67ecf46860f0f1998cf086e6ad293973
BLAKE2b-256 87bcb1a99f99215c3fe421ea2cc9ea4f0b54ecb0edc833808494a4327e35e301

See more details on using hashes here.

File details

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

File metadata

  • Download URL: python_dp-1.0.1-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.50.2 CPython/3.6.12

File hashes

Hashes for python_dp-1.0.1-cp36-cp36m-manylinux1_x86_64.whl
Algorithm Hash digest
SHA256 88f7d317560c96e8c0b0a71e0d312f1d83f02133cc9c419a618fe301e6ade794
MD5 81593b6a0c615c29dc5a8512be5a2cb1
BLAKE2b-256 ca63be58468487e4eb39bb6d0e6ff845e889cd780b508f78e403d1b44bf03c7e

See more details on using hashes here.

File details

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

File metadata

  • Download URL: python_dp-1.0.1-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.50.2 CPython/3.6.12

File hashes

Hashes for python_dp-1.0.1-cp36-cp36m-macosx_10_15_x86_64.whl
Algorithm Hash digest
SHA256 8292697d7569444bf176eb44d782c9f31515076cadb4c096c71f5eb88261055f
MD5 6845716a97589f9f2450fbbb0b88455d
BLAKE2b-256 b160dfb0f5c226c4e9ea35fe7e9b5e62462820f276c6e9c2ad94b0421f008f02

See more details on using hashes here.

File details

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

File metadata

  • Download URL: python_dp-1.0.1-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.50.2 CPython/3.5.4

File hashes

Hashes for python_dp-1.0.1-cp35-cp35m-win_amd64.whl
Algorithm Hash digest
SHA256 9a0c72602ea2f3fc03814da777560c78078e52c21a389ebabb0c287e434f32fc
MD5 f7b2a4c7f7dfcffcef7e739104e21ac4
BLAKE2b-256 5f1a69702803df621c3c973bd4abdcadbf1f48d252c68fdaf9d7de40f523752a

See more details on using hashes here.

File details

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

File metadata

  • Download URL: python_dp-1.0.1-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.50.2 CPython/3.5.10

File hashes

Hashes for python_dp-1.0.1-cp35-cp35m-manylinux1_x86_64.whl
Algorithm Hash digest
SHA256 31cb8c480c9e6fc1635488292db91c84fad467c2ca04402a327443eefb1eba3c
MD5 4b5c4f1d8b78cd27f8cfe33ff488d925
BLAKE2b-256 a2b0ca9fcee934f0dcb7155b6eb43944e2f32994ea20af7dd95a23f5e1fc3052

See more details on using hashes here.

File details

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

File metadata

  • Download URL: python_dp-1.0.1-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.50.2 CPython/3.5.10

File hashes

Hashes for python_dp-1.0.1-cp35-cp35m-macosx_10_15_x86_64.whl
Algorithm Hash digest
SHA256 6f894a561bec048178a040836777afff494a43d5e518c098441765ab96cf6a8a
MD5 56d9a66cb697bb00e696fd66ea4edd24
BLAKE2b-256 f04be0cf47934650267e22c49a1bdb42e182946f9227d2714e8a3c55228fb1d3

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