Skip to main content

CI PyPI DOI

TabDGP

A data-generating process (DGP) for grouped and flat tables.

TabDGP simulates tabular datasets from a random structural causal model (SCM) and aims to reproduce the quirks of real data. Each table comes with the graph and the settings that generated it.

Alpha. Release 0.5 draws grouped and flat tables with an outcome y, from the SCM or from a model's outcome. The SCM's defaults are round guesses, and Glmm's are checked against real tables; the rest is planned below. Before 1.0, a release may change the dataset a key draws.

Highlights

  • Grouped or flat. One to three grouping factors by default, nested or crossed, with 2 to 400 groups each. A covariate varies by row or is constant within the groups of one factor. Scm.flat() draws none.
  • White-box. Each dataset carries its graph, latent nodes, column metadata and hyperparameters.
  • Reproducible. A dataset is a pure function of its key (a seed and an index) and the hyperprior, whatever batch or worker draws it.
  • Model-free outcome. One node y is drawn by default as the last node of the SCM: continuous, binary, categorical, ordered or count.
  • Model-based outcome. Instead of the SCM's node, modelOutcome draws y from a generalized linear mixed model (GLMM) on the covariates (e.g. Glmm(family='bernoulli')). Supported likelihoods are Gaussian, Bernoulli, Poisson, Student-t, negative binomial, latent-noise Bernoulli, Gamma, and Beta. The true parameters are returned with the priors they were drawn from. Glm skips random effects, Glmm(family='gaussian', deviation_scale=0.3) adds a known misspecification. You can also pass your own model as a function of the covariates by defining it as a Callable.
  • Bring your own covariates. Covariates.fromPandas reads a table, and modelOutcome draws a model's outcome on it. You can use this semi-synthetic data for oracle tests or power analysis.

Install

pip install tabdgp

Quickstart

from tabdgp import Glmm, Scm, drawDataset, modelOutcome

scm = Scm.grouped(rows=100, design_columns=5)
dataset = drawDataset(seed=0, index=0, scm=scm)  # the key: a seed and an index
unit = dict(zip(dataset.graph.names, dataset.graph.unit))  # per row, or per group of a factor
for name, column in dataset.metadata.items():
    values = dataset.columns[name][:3].round(2)
    print(f'{name:2} {column.type:11} per {unit[name]:3} {values}')
glmm = Glmm(family='gaussian')
outcome = modelOutcome(seed=0, index=0, covariates=dataset.covariates, model=glmm)
print(f'fixed: {" + ".join(outcome.fixed_terms)}')
for factor, terms in outcome.random_terms.items():
    print(f'random per {factor}: {" + ".join(terms)}')
g0 categorical per g0  [4 5 2]
g1 categorical per g1  [ 6 22 29]
g2 categorical per g2  [7 7 5]
x0 binary      per row [1 0 1]
x1 binary      per row [0 1 0]
x2 continuous  per g2  [1.77 1.77 2.66]
x3 binary      per row [0 0 1]
x4 binary      per g2  [0 0 1]
y  continuous  per row [0.76 0.62 0.93]
fixed: intercept + x0 + x1 + x2 + x3 + x4
random per g0: intercept + x2
random per g1: intercept
random per g2: intercept + x1

An outcome y can also be sampled based on a model and the table's covariates. The built-in Glmm model also returns the drawn latent parameters.

import pandas as pd

from tabdgp import Covariates, Glmm, modelOutcome

table = pd.DataFrame(
    {
        'school': ['a', 'a', 'a', 'b', 'b', 'b', 'c', 'c', 'c'],  # the grouping factor
        'age': [11.2, 12.5, 10.8, 13.1, 11.9, 12.2, 10.5, 12.8, 11.4],  # floats: continuous
        'female': [1, 0, 1, 1, 0, 0, 1, 0, 1],  # two values: binary
        'books': [3, 10, 0, 25, 7, 2, 14, 5, 8],  # integers: a count
    }
)
covariates = Covariates.fromPandas(table, factors=['school'])
outcome = modelOutcome(seed=0, index=0, covariates=covariates, model=Glmm(family='gaussian'))
for term, beta in zip(outcome.fixed_terms, outcome.parameters.beta):
    print(f'{term:9} {beta:5.2f}')

The true fixed effects:

intercept  2.63
age       -0.00
female     0.01
books      0.30

Planned

  • Quirk axes: group confounding, rare levels, ties, bounds, near dependence and more.
  • Finetuning the hyperprior's parameters to any batch of datasets, scored by tabdgp.fidelity (tabdgp[fidelity]). Group presets are tuned against mixedbench.
  • Within-group time and a binary treatment.

Contributing

Issues and pull requests are welcome; see CONTRIBUTING.md.

License

Apache-2.0.

Metadata

Release files for tabdgp 0.5.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 tabdgp 0.5.0
File Size Uploaded Provenance Actions
tabdgp-0.5.0.tar.gz 16.4 MB With provenance Details for tabdgp-0.5.0.tar.gz

Built distribution (wheel)

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

Total release size: 16.5 MB

Release files / tabdgp-0.5.0.tar.gz

Download URL tabdgp-0.5.0.tar.gz
Size 16.4 MB
Tags Source
SHA-256 checksum
How to use checksums
d4496f6690e2818d874742c74f156f86f2cd3f37289b54b2a9693eaf07a377ef
BLAKE2b-256 checksum
How to use checksums
70df2b7181481aab4cf389c1d02324c351d61dadb079847adef65c6829455da2
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

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.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Nov 6, 2026.

Transparency log

Release files / tabdgp-0.5.0-py3-none-any.whl

Download URL tabdgp-0.5.0-py3-none-any.whl
Size 48.4 kB
Tags Python 3
SHA-256 checksum
How to use checksums
fa484957d2729d2d1158c2563259923d83d2891854ec79f6ace73df021f528bf
BLAKE2b-256 checksum
How to use checksums
39471cc765f89b87e1e61087ee43f162595412e24b6da4dacabca5d19d3c47dd
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

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.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Nov 6, 2026.

Transparency log

Security for tabdgp 0.5.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.

Full provenance

Both files in this release have been uploaded with provenance metadata.

Select from 2 files

Attestation for tabdgp-0.5.0.tar.gz

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Nov 6, 2026.

Transparency log

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.

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