Skip to main content
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
# Basic Structure: `BoundedMean(epsilon: float, lower_bound: Union[int, float, None], upper_bound: Union[int, float, None])`
# `epsilon`: a Double, between 0 and 1, denoting the privacy threshold,
#            measures the acceptable loss of privacy (with 0 meaning no loss is acceptable)
x = BoundedMean(epsilon=0.6, lower_bound=1, upper_bound=10)

# If the lower and upper bounds are not specified,
# PyDP automatically calculates these bounds
# x = BoundedMean(epsilon: float)
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

Metadata

Release files for python-dp 1.1.5

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Built distributions (wheels)

Table of built distributions (wheels) for python-dp 1.1.5
File Actions
python_dp-1.1.5-cp314-cp314-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl CPython 3.14 CPython 3.14 Linux glibc 2.28+ x86-64, Linux glibc 2.27+ x86-64 Details for python_dp-1.1.5-cp314-cp314-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl
python_dp-1.1.5-cp314-cp314-macosx_15_0_universal2.whl CPython 3.14 CPython 3.14 macOS 15.0+ universal2 (ARM64, x86-64) Details for python_dp-1.1.5-cp314-cp314-macosx_15_0_universal2.whl
python_dp-1.1.5-cp313-cp313-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl CPython 3.13 CPython 3.13 Linux glibc 2.28+ x86-64, Linux glibc 2.27+ x86-64 Details for python_dp-1.1.5-cp313-cp313-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl
python_dp-1.1.5-cp313-cp313-macosx_15_0_universal2.whl CPython 3.13 CPython 3.13 macOS 15.0+ universal2 (ARM64, x86-64) Details for python_dp-1.1.5-cp313-cp313-macosx_15_0_universal2.whl
python_dp-1.1.5-cp312-cp312-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl CPython 3.12 CPython 3.12 Linux glibc 2.27+ x86-64, Linux glibc 2.28+ x86-64 Details for python_dp-1.1.5-cp312-cp312-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl
python_dp-1.1.5-cp312-cp312-macosx_15_0_universal2.whl CPython 3.12 CPython 3.12 macOS 15.0+ universal2 (ARM64, x86-64) Details for python_dp-1.1.5-cp312-cp312-macosx_15_0_universal2.whl
python_dp-1.1.5-cp311-cp311-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl CPython 3.11 CPython 3.11 Linux glibc 2.28+ x86-64, Linux glibc 2.27+ x86-64 Details for python_dp-1.1.5-cp311-cp311-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl
python_dp-1.1.5-cp311-cp311-macosx_15_0_universal2.whl CPython 3.11 CPython 3.11 macOS 15.0+ universal2 (ARM64, x86-64) Details for python_dp-1.1.5-cp311-cp311-macosx_15_0_universal2.whl

Total release size: 17.3 MB

Release files / python_dp-1.1.5-cp314-cp314-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl

Download URL python_dp-1.1.5-cp314-cp314-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl
Size 3.2 MB
Tags CPython 3.14 Linux glibc 2.27+ x86-64 Linux glibc 2.28+ x86-64
SHA-256 checksum
How to use checksums
32dde006cffb1e9c3d9469ddc1986d968bc7b87ae404313fd6eb8116751790e7
BLAKE2b-256 checksum
How to use checksums
b08075f5cf75e9fcc62874587adab89c2c454f1f7d1ab9d369957b2cdae59e4a
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.14.4

Release files / python_dp-1.1.5-cp314-cp314-macosx_15_0_universal2.whl

Download URL python_dp-1.1.5-cp314-cp314-macosx_15_0_universal2.whl
Size 1.2 MB
Tags CPython 3.14 macOS 15.0+ universal2 (ARM64, x86-64)
SHA-256 checksum
How to use checksums
1a577b535a5ade79aa2273ae37a436ae71437a6ca6c66d81b9cb4059d046c25c
BLAKE2b-256 checksum
How to use checksums
398c778ff3989c33aa6559e2f59563cbe704cb781ca1f1e42741b3e9ed8b187d
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.14.4

Release files / python_dp-1.1.5-cp313-cp313-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl

Download URL python_dp-1.1.5-cp313-cp313-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl
Size 3.2 MB
Tags CPython 3.13 Linux glibc 2.27+ x86-64 Linux glibc 2.28+ x86-64
SHA-256 checksum
How to use checksums
40cfd8f9a06b1288e6563590c81bfcdfbf3f35437c96fa83595d4e1be04a8a60
BLAKE2b-256 checksum
How to use checksums
840a9eebda38854bb874e23db389af09369f44ce1a4ff0280765a331dbd15856
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.13.13

Release files / python_dp-1.1.5-cp313-cp313-macosx_15_0_universal2.whl

Download URL python_dp-1.1.5-cp313-cp313-macosx_15_0_universal2.whl
Size 1.2 MB
Tags CPython 3.13 macOS 15.0+ universal2 (ARM64, x86-64)
SHA-256 checksum
How to use checksums
e57571098bd6f1b18f4c601ea43ae7771f43519509e573fe6e4dc76467cdffde
BLAKE2b-256 checksum
How to use checksums
968995b0d5fe3f156811b77d88a8bdff1a8d1fe26ec3ba7411a3c23fd8eac80c
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.13.13

Release files / python_dp-1.1.5-cp312-cp312-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl

Download URL python_dp-1.1.5-cp312-cp312-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl
Size 3.2 MB
Tags CPython 3.12 Linux glibc 2.27+ x86-64 Linux glibc 2.28+ x86-64
SHA-256 checksum
How to use checksums
9dd5c8fbac6398c96a90f0644601bd36ccc7f35dbc4d09376f9f4489e7984621
BLAKE2b-256 checksum
How to use checksums
3db06032a974a9d293ebbb8565a6947a831484a0e076787a8c9a13e6171361dc
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.12.13

Release files / python_dp-1.1.5-cp312-cp312-macosx_15_0_universal2.whl

Download URL python_dp-1.1.5-cp312-cp312-macosx_15_0_universal2.whl
Size 1.2 MB
Tags CPython 3.12 macOS 15.0+ universal2 (ARM64, x86-64)
SHA-256 checksum
How to use checksums
cc0fe9e1557eaa761663ccd379818838d88d139983c47ce75ef029ae479d40cb
BLAKE2b-256 checksum
How to use checksums
7010a15bfbf2026a7432e53aa15d7d6c19890ada91f5b174abbc5651bfbebdad
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.12.10

Release files / python_dp-1.1.5-cp311-cp311-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl

Download URL python_dp-1.1.5-cp311-cp311-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl
Size 3.2 MB
Tags CPython 3.11 Linux glibc 2.27+ x86-64 Linux glibc 2.28+ x86-64
SHA-256 checksum
How to use checksums
0400782a833476537e0caed7c9755cae826145410dea6e8676c8a23cb6968500
BLAKE2b-256 checksum
How to use checksums
bc05de47590f7cbd8515d5b9a60ffd7c62059040ba23ff1fa5f878c3f887298e
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.11.15

Release files / python_dp-1.1.5-cp311-cp311-macosx_15_0_universal2.whl

Download URL python_dp-1.1.5-cp311-cp311-macosx_15_0_universal2.whl
Size 1.2 MB
Tags CPython 3.11 macOS 15.0+ universal2 (ARM64, x86-64)
SHA-256 checksum
How to use checksums
f5566ba4a6529fb1aa2bb0c0c7eb9cb97c6e0f91fcd327ec5a70f18f6b81414a
BLAKE2b-256 checksum
How to use checksums
e044a7f329156f22a3eea41f40887d492bf3dd399bc7bb209d0db1b6cdd704ec
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.11.9

Security for python-dp 1.1.5

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Release history Release notifications | RSS feed

This release

1.1.5 This release

8 release files No provenance

0.1.3

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page