Skip to main content

A logger wrapper for DiffPrivLib

Project description

DiffPrivLib Logger

Serialize and deserialize DiffPrivLib pipelines to and from JSON.

It is inspired from opendp-logger and a first version was made by Oblivious for the UN PET Lab Hackathon 2022.

Example

from sklearn.pipeline import Pipeline
from diffprivlib import models

pipeline = Pipeline(
    [
        (
            "scaler",
            models.StandardScaler(
                bounds=([17, 1, 0, 0, 1], [90, 160, 10000, 4356, 99])
            ),
        ),
        ("pca", models.PCA(2, data_norm=5, centered=True)),
        ("lr", models.LogisticRegression(data_norm=5)),
    ]
)

Serialise

from diffprivlib_logger import serialise_pipeline

serialised_pipeline = serialise_pipeline(pipeline)

Deserialise

from diffprivlib_logger import deserialise_pipeline

deserialised_pipeline = serialise_pipeline(serialised_pipeline)

Verify

assert pipeline == deserialised_pipeline

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

diffprivlib_logger-0.0.1.tar.gz (4.9 kB view hashes)

Uploaded Source

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