How ibm/differential-privacy-library works
Main components
• Core Library Package (diffprivlib/)
• Mechanisms subpackage
• Models subpackage
• Tools subpackage
• Accountant module
• Transforms module
• Utils & validation modules
• External Dependencies
• NumPy, SciPy, scikit-learn, Matplotlib (used in examples)
• pytest (testing)
• Sphinx (documentation)
• setuptools (build & packaging)
• Supporting Artifacts
• Notebooks (Jupyter examples)
• Docs (Sphinx source & HTML output)
• Tests (pytest suite)
• CI/CD Workflows (GitHub Actions, CodeQL, codecov)
• Packaging & distribution (setup.py, PyPI)
Relationships & data flows
• Mechanisms are the foundational building blocks; Models and Tools import and invoke Mechanisms.
• Transforms sit alongside Mechanisms to preprocess or postprocess data within Mechanisms.
• Accountant tracks privacy budget across calls to Mechanisms within Models/Tools.
• Notebooks import Models, Tools, Mechanisms to demonstrate usage.
• Tests import all modules to validate correctness.
• CI/CD pipelines run tests, generate coverage, build docs, and push packaged releases.
Architectural patterns & design principles
• Layered architecture:
Layer 1 (Core DP primitives): diffprivlib.mechanisms, transforms, utils
Layer 2 (Higher‐level abstractions): diffprivlib.models, diffprivlib.tools, diffprivlib.accountant
Layer 3 (Interfaces & examples): notebooks, CLI (via setup.py entry points, if any)
• Modular, extensible design: clear separation between “Mechanisms” and “Models” so new DP algorithms can plug in.
• Test‐driven development: nearly every module has a corresponding pytest file.
• Continuous integration and documentation generation ensure code quality and user guidance.