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

Uploaded CPython 3.9 Windows x86-64

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

Uploaded CPython 3.9

python_dp-1.1.0rc3-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.0rc3-cp38-cp38-win_amd64.whl (1.8 MB view details)

Uploaded CPython 3.8 Windows x86-64

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

Uploaded CPython 3.8

python_dp-1.1.0rc3-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.0rc3-cp37-cp37m-win_amd64.whl (1.8 MB view details)

Uploaded CPython 3.7m Windows x86-64

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

Uploaded CPython 3.7m

python_dp-1.1.0rc3-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.0rc3-cp36-cp36m-win_amd64.whl (1.8 MB view details)

Uploaded CPython 3.6m Windows x86-64

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

Uploaded CPython 3.6m

python_dp-1.1.0rc3-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.0rc3-cp39-cp39-win_amd64.whl.

File metadata

  • Download URL: python_dp-1.1.0rc3-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.0rc3-cp39-cp39-win_amd64.whl
Algorithm Hash digest
SHA256 a3392b5a30ecf9eb80c42c3f1a0efc219f40e22fb5d6b3abc9107d8d7c2df8f8
MD5 7341143cd47453f9310a0dba71c7f5f2
BLAKE2b-256 d31f3ba4e68ba1da7e989db62aee85c5e83abfd8dd581ced8240d9a0479b1651

See more details on using hashes here.

File details

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

File metadata

  • Download URL: python_dp-1.1.0rc3-cp39-cp39-manylinux1_x86_64.whl
  • Upload date:
  • Size: 3.3 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.0rc3-cp39-cp39-manylinux1_x86_64.whl
Algorithm Hash digest
SHA256 2ef35f5d3fdbd5a70bea9dd6cbf4c87a465e39427daf36c0c461ab406da61e9c
MD5 51d6d0182b4d069df7df3917f47a0205
BLAKE2b-256 222bd2a477f2d88dfd72ca809dea74ab0b8b801b9b92478b77aa5f40ec1ee8e7

See more details on using hashes here.

File details

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

File metadata

  • Download URL: python_dp-1.1.0rc3-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.0rc3-cp39-cp39-macosx_10_14_x86_64.whl
Algorithm Hash digest
SHA256 825a0aa3145ab7faa8650db05f5c7fb3daf86be5de378a31b750fc53656d730a
MD5 f59f250e9d84d45aebca9258d3cebaa9
BLAKE2b-256 96092c92ebab4c8c365f12836c213ad18568128e52fa889c5a7a1a6223a6b183

See more details on using hashes here.

File details

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

File metadata

  • Download URL: python_dp-1.1.0rc3-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.0rc3-cp38-cp38-win_amd64.whl
Algorithm Hash digest
SHA256 d871c81183f6b2c71edcd1028a51ecfbf068a718a668f7e24294cd264d0f83ce
MD5 df263c01bf8121fb526c9f08df1259aa
BLAKE2b-256 183bde30202ec58a74992e497891101b99de4c47c9c930b36ad714c4fda4b954

See more details on using hashes here.

File details

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

File metadata

  • Download URL: python_dp-1.1.0rc3-cp38-cp38-manylinux1_x86_64.whl
  • Upload date:
  • Size: 3.3 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.0rc3-cp38-cp38-manylinux1_x86_64.whl
Algorithm Hash digest
SHA256 0f40534e7fb754d3913d405159c6546da942f71e9f208c691567a94e78d431eb
MD5 1d84c3337ca7f343be55c71c703e0d47
BLAKE2b-256 d7c29a905a40a7549fec835ef21f26c1765494c4b25a474b4eb4f52402434f81

See more details on using hashes here.

File details

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

File metadata

  • Download URL: python_dp-1.1.0rc3-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.0rc3-cp38-cp38-macosx_10_14_x86_64.whl
Algorithm Hash digest
SHA256 056525a5e827c5047e64af599bd0d389fd66a3113328b14786089670e0df5f93
MD5 3afd7d06dd594a8ce20606a15972172c
BLAKE2b-256 724e65def6676fcc8ed17750663db196a11fc8c948a5b8ec488083bb5046231b

See more details on using hashes here.

File details

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

File metadata

  • Download URL: python_dp-1.1.0rc3-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.0rc3-cp37-cp37m-win_amd64.whl
Algorithm Hash digest
SHA256 8d7a723d4efe729b996da7e7269ae628f51731735787fdda1defa2b72f1780eb
MD5 4176f1cd39d0af4e39b600676950e27f
BLAKE2b-256 d9e303cb8c41ff313aba58b83c7746a8209a58455ed93fc4d2df0fdf4b25a925

See more details on using hashes here.

File details

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

File metadata

  • Download URL: python_dp-1.1.0rc3-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.0rc3-cp37-cp37m-manylinux1_x86_64.whl
Algorithm Hash digest
SHA256 34376cad1caefb3ccaf35908ee5798dba9ff3209640edb05a0f9dcb0b28b6f50
MD5 dc58763af163adb62036511eadd22f34
BLAKE2b-256 e8205a844e81d384f283eb87107f4e1f474b9c689de0e70c4c2026c0f32324cf

See more details on using hashes here.

File details

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

File metadata

  • Download URL: python_dp-1.1.0rc3-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.0rc3-cp37-cp37m-macosx_10_14_x86_64.whl
Algorithm Hash digest
SHA256 7cbce3048a565d0739d58139b941330da1a8aad4b7a591228e5d404f91f23032
MD5 43e3eeb2121493fb977fb0202987017b
BLAKE2b-256 c50a3a82bd694ab3d314d4be76eacda8f5baf1b4b6af55bdf60f959e18ba0dcc

See more details on using hashes here.

File details

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

File metadata

  • Download URL: python_dp-1.1.0rc3-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.0rc3-cp36-cp36m-win_amd64.whl
Algorithm Hash digest
SHA256 679948548fb0170ab6a22c94d58c3d1c8db78b61d490ac11520407909ac68376
MD5 3f7aa8a7619127442d76307d1e155f32
BLAKE2b-256 5e3b28b2510beb3bc16bba156b4bb8e5532e7f0974f7c7394e7eddb37bc8e591

See more details on using hashes here.

File details

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

File metadata

  • Download URL: python_dp-1.1.0rc3-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.0rc3-cp36-cp36m-manylinux1_x86_64.whl
Algorithm Hash digest
SHA256 9c598311525b5b9819ddd72a6ac600d3115788e30e4ed5b60df18bce2d5a52dd
MD5 2f683e246c4a43debc8f1e38b00eda6b
BLAKE2b-256 f7787f7c700e417ddf927831441466d18c26bdd81188833ef232b25bdda22351

See more details on using hashes here.

File details

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

File metadata

  • Download URL: python_dp-1.1.0rc3-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.0rc3-cp36-cp36m-macosx_10_14_x86_64.whl
Algorithm Hash digest
SHA256 a1aa0940ac4369a2631890b8e1b30143b47585fe1813a1ce8482c97e35b4d26c
MD5 de79a22eb65a9d0680e37955a5a783f8
BLAKE2b-256 80a833c1197c995aa83bc70ac198a3ed1b304667c15abcd7475947442aabd516

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