Skip to main content

micro

Conditional microdata synthesis using normalizing flows.

PyPI Tests Docs

Overview

micro synthesizes survey microdata while preserving:

  • 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 micro

Quick Start

from micro 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 micro?

Feature micro 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/micro

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{micro2024,
  author = {Cosilico},
  title = {micro: Conditional microdata synthesis using normalizing flows},
  year = {2024},
  url = {https://github.com/CosilicoAI/micro}
}

License

MIT License - see LICENSE for details.

Metadata

Release files for microsynth 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 microsynth 0.1.0
File Size Uploaded
microsynth-0.1.0.tar.gz 21.2 kB Details

Built distribution (wheel)

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

Total release size: 36.6 kB

Release files / microsynth-0.1.0.tar.gz

Download URL microsynth-0.1.0.tar.gz
Size 21.2 kB
Tags Source
SHA-256 checksum
How to use checksums
1f4f8c312ec24aee26aa6e6deebe06e0217934572b8dfe757fc9486bcc8ff9bd
BLAKE2b-256 checksum
How to use checksums
6c5d0b2bfdaf8b8920a5da8af799e133a450003e8862c439181060b5f5b6049d
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.14.2

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

Download URL microsynth-0.1.0-py3-none-any.whl
Size 15.4 kB
Tags Python 3
SHA-256 checksum
How to use checksums
7a3983270ebf76d524c8b4613712337f337404a7132a474e3eff9a872bc2cd22
BLAKE2b-256 checksum
How to use checksums
58b82f3ca105a41d1e05cfe340db620ece98f2f79b0374db8a66ec21028fd6fe
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