Skip to main content

Evaluation of how good a synthetic dataset is compared to the original with presuppossing structural constraints

Project description

MAP-alignment fidelity and dataset distance for synthetic tabular data

This package implements the one-sided MAP-alignment fidelity statistic introduced by Chattopadhyay et al. and described in the manuscript “How Good Is Your Synthetic Data?”.

The core idea

For a synthetic record to be realistic, each coordinate should agree with the conditional MAP prediction inferred from real data.

Formally, for a data record x and coordinate i:

υ(x, i) = φ_i(x_i | x_{-i}) / max_y φ_i(y | x_{-i})

Averaged over samples and coordinates:

Υ(D) in [0,1]
  • High Υ: synthetic preserves real conditional structure

  • Low Υ: structural distortion (even if marginals / covariance match)

Installation

pip install lsynth

Quick Example

import pandas as pd
from lsynth import compute_upsilon

df_real = pd.read_csv("gss_2018.csv").sample(200)

ups_lsm, syn_lsm = compute_upsilon(
    num=100,
    model_path="gss_2018.joblib",
    generate=True,
    gen_algorithm="LSM",
    orig_df=df_real,
    n_workers=8,
)

print("LSM mean Upsilon:", ups_lsm.mean())

Interpretation

  • ~1.0: synthetic matches conditional structure closely

  • ~0.7: Gaussian-like distortions

  • < 0.7: strong structural mismatch

Why MAP-alignment?

Because covariance matching is insufficient.

Section VII of the manuscript gives explicit examples where:

  • Real and synthetic share identical means, variances, covariance matrices

  • Yet they differ strongly in conditional structure

  • MAP-alignment catches the discrepancy immediately

This method:

  • Detects nonlinear and higher-order structure

  • Avoids feature-embedding artifacts

  • Comes with finite-sample uncertainty control

Supported Generators

  • "LSM": use QuasiNet as a generative model via qsample

  • "BASELINE": independent-column null model

  • "CTGAN": uses SDV CTGAN synthesizer

  • Custom generators also supported

Citation

Chattopadhyay I, et al.
"How Good Is Your Synthetic Data?"

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

lsynth-0.1.10.tar.gz (11.8 kB view details)

Uploaded Source

File details

Details for the file lsynth-0.1.10.tar.gz.

File metadata

  • Download URL: lsynth-0.1.10.tar.gz
  • Upload date:
  • Size: 11.8 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.1 CPython/3.12.7

File hashes

Hashes for lsynth-0.1.10.tar.gz
Algorithm Hash digest
SHA256 74f53b7de404aee064b2eebc3858424157b50f41ef5535c7b5f0462c3784a037
MD5 d9018f157e47317b8a7065b2a02e328b
BLAKE2b-256 ca94d91f5a12a920cd4a6e9a1521a0c4b5ef20d8dcf4cff90c3e1f3aed53a8be

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page