Source-linked AI summary
Diffprivlib: The IBM Differential Privacy Library
Naoise Holohan, Stefano Braghin, Pól Mac Aonghusa, Killian Levacher
TL;DR
Differential privacy research lacks a single codebase for implementing its growing body of methods and applications. This paper presents diffprivlib, an accessible open-source Python library that unifies mechanisms, machine-learning models, and analytics tools. The library supports familiar NumPy and Scikit-learn workflows, while its worked example reports 95% of non-private accuracy on UCI Adult at ϵ = 0.05.
Problem
Differential privacy applications exist in a fragmented environment of different languages, coding styles, and incomplete or unmaintained repositories.
Method
The paper presents diffprivlib, an open-source Python library combining differential privacy mechanisms with machine-learning models and analytics tools.
Results
Diffprivlib provides mechanisms, familiar NumPy and Scikit-learn integration, and a worked example reaching 95% of non-private accuracy on UCI Adult at ϵ = 0.05.
Takeaways & Limitations
The library is designed to support accessible investigation, experimentation, development, and contribution across differential privacy applications.
Takeaways & Limitations
PrivacyLeakWarning indicates that omitted or incorrect data bounds can cause additional privacy leakage and prevent strict differential privacy.
Abstract
from arXiv · showhide
Since its conception in 2006, differential privacy has emerged as the de-facto standard in data privacy, owing to its robust mathematical guarantees, generalised applicability and rich body of literature. Over the years, researchers have studied differential privacy and its applicability to an ever-widening field of topics. Mechanisms have been created to optimise the process of achieving differential privacy, for various data types and scenarios. Until this work however, all previous work on differential privacy has been conducted on a ad-hoc basis, without a single, unifying codebase to implement results. In this work, we present the IBM Differential Privacy Library, a general purpose, open source library for investigating, experimenting and developing differential privacy applications in the Python programming language. The library includes a host of mechanisms, the building blocks of differential privacy, alongside a number of applications to machine learning and other data analytics tasks. Simplicity and accessibility has been prioritised in developing the library, making it suitable to a wide audience of users, from those using the library for their first investigations in data privacy, to the privacy experts looking to contribute their own models and mechanisms for others to use.
1 INTRODUCTION
Differential privacy research has produced many applications and mechanisms, but implementations remain fragmented across languages, coding styles, and repositories. Diffprivlib addresses this gap with an accessible, open-source Python library combining privacy mechanisms, applications, and tools.
- Differential privacy offers broad applicability and rigorous mathematical privacy guarantees across fields ranging from histograms to deep learning.
- Existing differential privacy applications are fragmented across programming languages, coding styles, and incomplete or unmaintained repositories.
- Diffprivlib is a general-purpose, open-source Python library for bringing together differential privacy applications and fundamentals.
- The library includes mechanisms for adding noise and uses them within machine-learning models and other tools to satisfy differential privacy.
2 OVERVIEW
Diffprivlib prioritizes accessibility for users with different levels of privacy expertise by building on familiar Python, NumPy, and Scikit-learn conventions. Its three modules organize mechanisms, private models, and privacy-preserving analytics tools, with supporting tests, examples, and documentation.
- Python was selected for accessibility, machine-learning capabilities, and an active user community, and diffprivlib requires Python 3.4.
- Diffprivlib integrates with Scikit-learn and mirrors NumPy functionality so users can work with familiar interfaces and tools.
- The library consists of mechanisms, models, and tools modules for differential privacy applications, private machine learning, and data analytics.
- GitHub resources include unit tests and Jupyter notebook examples, while documentation is hosted on Read the Docs.
3 LIBRARY CONTENTS
The library contents provide reusable differential privacy mechanisms, Scikit-learn-compatible models, NumPy-oriented analytics tools, and warnings for configuration problems. These components support both direct experimentation and integrated privacy-preserving applications.
- Mechanisms: Diffprivlib mechanisms are grouped by type, directly importable, and configured through methods for privacy parameters, sensitivity, and randomization.
- Machine Learning Models: Private models mirror Scikit-learn syntax, allowing users to switch from a non-private model by changing the import while retaining compatible pipelines.
- Mechanisms: The mechanism example sets epsilon to 0.5, sensitivity to 1, and randomizes input 3 to produce 5.835104866820303.
- Machine Learning Models: Models can use data bounds or sample norms to avoid privacy leakage, and users receive warnings when these parameters are omitted or inadequate.
- Tools: The tools module provides differentially private histograms, means, variances, and standard deviations while leveraging NumPy functionality.
- Troubleshooting: PrivacyLeakWarning indicates incorrect configuration that may prevent strict differential privacy, while DiffprivlibCompatibilityWarning concerns unsupported inherited parameters.
4 WORKED EXAMPLE
The worked example applies diffprivlib’s differentially private Gaussian naïve Bayes classifier to Iris data, then examines accuracy across privacy levels. It also reports stronger accuracy retention on the larger UCI Adult dataset.
- Gaussian naïve Bayes adds noise to learned feature means and variances, decoupling the model from its training data.
- The example uses an 80/20 Iris train/test split and fits diffprivlib’s GaussianNB model with Scikit-learn-compatible code.
- Figure 1 plots average accuracy over 30 simulations against ϵ for the differentially private Iris classifier.
- Unspecified data bounds trigger a PrivacyLeakWarning because the model computes bounds from the training data, causing additional privacy leakage.Bounds should instead be determined independently, using domain knowledge, and supplied during initialization.
- 95% of non-private accuracy is reached at ϵ = 0.05 on the larger UCI Adult dataset, whereas Iris requires a higher ϵ threshold to maintain accuracy.The Iris dataset contains 150 samples; the UCI Adult dataset contains 48 842 samples.
5 CONCLUSION
The paper presents diffprivlib as a general-purpose, open-source Python library for developing differential privacy applications and tools. It emphasizes usability, integration with NumPy and Scikit-learn, and future community development.
- Diffprivlib supports simulation, experimentation, and development of differential privacy applications and tools.
- The library integrates with NumPy and Scikit-learn and is designed for user-friendly differential privacy machine-learning tasks.
- As an open-source project, diffprivlib welcomes contributions to expand and enhance its functionality.