micro
Conditional microdata synthesis using normalizing flows.
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)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| microsynth-0.1.0.tar.gz | 21.2 kB | Without provenance | Details for microsynth-0.1.0.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| microsynth-0.1.0-py3-none-any.whl | Python 3 | none | any | Details for microsynth-0.1.0-py3-none-any.whl |
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
|
Security for microsynth 0.1.0
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.