Skip to main content

microplex

Microdata synthesis and reweighting using normalizing flows.

PyPI Tests Docs

Overview

microplex creates rich, calibrated microdata through:

  • Conditional relationships: Generate target variables given demographics
  • Zero-inflated distributions: Handle variables that are 0 for many observations
  • Joint correlations: Preserve relationships between target variables
  • Hierarchical structures: Keep household/firm compositions intact

Installation

pip install microplex

Quick Start

from microplex import Synthesizer
import pandas as pd

# Load training data with known target variables
training_data = pd.read_csv("survey_with_income.csv")

# Initialize synthesizer
synth = Synthesizer(
    target_vars=["income", "expenditure", "savings"],
    condition_vars=["age", "education", "region"],
)

# Fit on training data
synth.fit(training_data, weight_col="weight", epochs=100)

# Generate synthetic targets for new demographics
new_demographics = pd.read_csv("demographics_only.csv")
synthetic = synth.generate(new_demographics)

Why microplex?

Feature microplex CT-GAN TVAE synthpop
Conditional generation ✅ ❌ ❌ ❌
Zero-inflation handling ✅ ❌ ❌ ⚠️
Exact likelihood ✅ ❌ ❌ N/A
Stable training ✅ ⚠️ ✅ ✅
Preserves source structure ✅ ❌ ❌ ⚠️

Use Cases

  • Survey enhancement: Impute income variables from tax data onto census demographics
  • Privacy-preserving synthesis: Generate synthetic data that preserves statistical properties without copying real records
  • Data fusion: Combine variables from multiple surveys with different sample designs
  • Missing data imputation: Fill in missing values conditioned on observed variables

Architecture

┌─────────────────────────────────────────────────────────┐
│                      Synthesizer                         │
├─────────────────────────────────────────────────────────┤
│                                                          │
│  Training:                                               │
│  ┌──────────┐    ┌──────────────┐    ┌──────────────┐  │
│  │ Training │───▶│ Transformer  │───▶│ Normalizing  │  │
│  │   Data   │    │ (log, std)   │    │    Flow      │  │
│  └──────────┘    └──────────────┘    └──────────────┘  │
│                                                          │
│  Generation:                                             │
│  ┌──────────┐    ┌──────────────┐    ┌──────────────┐  │
│  │ Context  │───▶│ Zero + Flow  │───▶│  Inverse     │  │
│  │  Vars    │    │   Sampling   │    │  Transform   │  │
│  └──────────┘    └──────────────┘    └──────────────┘  │
│                                                          │
└─────────────────────────────────────────────────────────┘

Documentation

Full documentation at cosilicoai.github.io/microplex

Benchmarks

See benchmarks/ for comparisons against:

  • CT-GAN: Conditional Tabular GAN (from SDV)
  • TVAE: Tabular VAE (from SDV)
  • Copulas: Gaussian copula synthesis (from SDV)
  • synthpop: CART-based synthesis (R package, via rpy2)

Citation

@software{microplex2024,
  author = {Cosilico},
  title = {microplex: Microdata synthesis and reweighting using normalizing flows},
  year = {2024},
  url = {https://github.com/CosilicoAI/microplex}
}

License

MIT License - see LICENSE for details.

Metadata

Release files for microplex 0.1.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for microplex 0.1.0
File Size Uploaded
microplex-0.1.0.tar.gz 21.3 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for microplex 0.1.0
File Interpreter ABI Platform
microplex-0.1.0-py3-none-any.whl Python 3 none any Details

Total release size: 36.8 kB

Release files / microplex-0.1.0.tar.gz

Download URL microplex-0.1.0.tar.gz
Size 21.3 kB
Tags Source
SHA-256 checksum
How to use checksums
28977e894dd0e500545b6529dfd2b2362493a8ab207aee70370715369631f429
BLAKE2b-256 checksum
How to use checksums
4a216eab643b40f500905fddc7ebdf4c8e3715af5d65697e7cac8ea86f1520c1
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.14.2

Release files / microplex-0.1.0-py3-none-any.whl

Download URL microplex-0.1.0-py3-none-any.whl
Size 15.5 kB
Tags Python 3
SHA-256 checksum
How to use checksums
3b2113afc1c891eb1cd30b170d4fa7b4b1eb5c05659ced82820004f74e917b39
BLAKE2b-256 checksum
How to use checksums
76c49774b31a70aa332a0411fcbd19034364270a7e0f0867b73c07236cedabe4
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.14.2

Release history Release notifications | RSS feed

This release

0.1.0 This release

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page