Skip to main content

A logger wrapper for Smartnoise Synth Table Transformer

Project description

Smartnoise Synth Logger

Logger for Smartnoise Synth Transformers

License: MIT Python ci tests

Serialize and deserialize Smartnoise Synth constraints to and from JSON. Constraints as specified in the Smartnoise Synth Transforms documentation: https://docs.smartnoise.org/synth/transforms/index.html with tt = TableTransformer(constraint).

Installation

Install with pip:

pip install smartnoise-synth-logger

Example

from snsynth.transform import (
    AnonymizationTransformer,
    BinTransformer,
    ChainTransformer,
    ClampTransformer,
    DropTransformer,
    LabelTransformer,
    LogTransformer,
    MinMaxTransformer,
    OneHotEncoder,
    StandardScaler,
)

constraints = {
    "id": AnonymizationTransformer("uuid4"),
    "email": "email", # also possible
    "income": ChainTransformer(
        [
            LogTransformer(),
            BinTransformer(bins=20, lower=0, upper=50),
        ]
    ),
    "height": ChainTransformer(
        [
            StandardScaler(lower=0, upper=1),
            BinTransformer(bins=20, lower=0, upper=1),
        ]
    ),
    "weight": ChainTransformer(
        [ClampTransformer(lower=10, upper=200), BinTransformer(bins=20)]
    ),
    "age": MinMaxTransformer(lower=0, upper=100),
    "sex": ChainTransformer(
        [LabelTransformer(nullable=True), OneHotEncoder()]
    ),
    "rank": LabelTransformer(nullable=False),
    "job": DropTransformer(),
}

Serialise

from smartnoise_synth_logger import serialise_constraints

serialised_constraints = serialise_constraints(constraints)

Deserialise

from smartnoise_synth_logger import deserialise_constraints

deserialised_constraints = deserialise_constraints(serialised_constraints)
tt = TableTransformer(deserialised_constraints)

It can now be expected that the deserialised_constraints has the same constraints as constraints.

NOTE: lambda function in AnonymizationTransformer are not supported.

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

smartnoise_synth_logger-0.0.4.tar.gz (6.6 kB view details)

Uploaded Source

File details

Details for the file smartnoise_synth_logger-0.0.4.tar.gz.

File metadata

File hashes

Hashes for smartnoise_synth_logger-0.0.4.tar.gz
Algorithm Hash digest
SHA256 644db993806c10d92fae7c1d122469c4776ebeff1314a96a28dc94cd751da200
MD5 0637299d5fc92b45934dd94b8802178d
BLAKE2b-256 0fa6f27e6cc048e4a188dda70332b90adf936c0956ac00c5ac197846326f44ec

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