Registry / data / decaf-synthetic-data

decaf-synthetic-data

JSON →
library0.1.7pypypi✓ verified 86d ago

DECAF (DEbiasing CAusal Fairness) is a Python library providing tools for generating synthetic data and debiasing causal effects. It implements methods to create synthetic datasets that capture complex causal relationships while mitigating various forms of bias, enabling researchers and practitioners to evaluate and develop fair causal inference models. Currently at version 0.1.7, the library is under active development with a focus on research-driven advancements.

pip install decaf-synthetic-data
INSTALL
IMPORT
SIG · DECAF-SYNTHETIC-DA
D
decaf-synthetic-data
datapythonv0.1.7
Install
Import
Disk
Pass rate
0/ 10
Env Coverage0 / 10
glibc
3.93.13
musl
3.93.13
Install & Compatibility
Where this runs
tested against v0.1.7 · pip install
no network on importno background threads
Install × environment matrix
Each cell = how many times install + import succeeded across repeated harness runs. Partial = flaky.
glibc = Debian/Ubuntu slim · musl = Alpine Linux
musl
glibc
py 3.10
✕ build_error
✕ timeout
py 3.11
✕ build_error
1/4 runs
py 3.12
✕ build_error
3/4 runs
py 3.13
✕ build_error
✕ build_error
py 3.9
✕ build_error
✕ timeout
Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

DECAF
from decaf import DECAF
SyntheticData
from decaf.synthetic_data import SyntheticData

This quickstart demonstrates how to use `SyntheticData` to generate a base dataset, then how to initialize and train the `DECAF` model with this data, and finally, generate new synthetic samples from the trained model. This workflow is typical for evaluating debiasing strategies.

import numpy as np from decaf import DECAF from decaf.synthetic_data import SyntheticData # 1. Generate initial synthetic data with a known structure n = 1000 # Number of samples p = 10 # Number of features seed = 42 sd = SyntheticData(n=n, p=p, seed=seed) data = sd.generate_data() # Returns a dictionary with 'x', 'a', 'y' X_orig = data['x'] # Features A_orig = data['a'] # Treatment Y_orig = data['y'] # Outcome print(f"Original X shape: {X_orig.shape}, A shape: {A_orig.shape}, Y shape: {Y_orig.shape}") # 2. Initialize and train the DECAF model # (using a small number of epochs for quick demonstration) model = DECAF(X_orig, A_orig, Y_orig, epochs=10, verbose=False, seed=seed) model.train() # 3. Generate new synthetic data using the trained DECAF model n_synthetic = 500 synthetic_X, synthetic_A = model.generate_synthetic_data(n_samples=n_synthetic) print(f"Synthetic X shape: {synthetic_X.shape}, Synthetic A shape: {synthetic_A.shape}") # Further steps would involve evaluating fairness or causal effects on this synthetic data
Debug
Known issues
breakingAs the library is in early development (version 0.1.x), expect potential API changes, breaking modifications, and new features in minor or patch releases.
fix
Always check the latest GitHub README and release notes (if any) before upgrading to new versions, and adapt your code as necessary.
affects: <1.0.0
gotchaThe `DECAF` model expects specific input formats (NumPy arrays) for features (X), treatment (A), and outcome (Y). Mismatched shapes or types can lead to errors during model initialization or training.
fix
Ensure `X`, `A`, and `Y` are NumPy arrays with appropriate dimensions (e.g., X as 2D, A and Y as 1D or 2D with one column). Review the quickstart for expected input formats.
affects: All
gotchaTraining `DECAF` models, especially on larger datasets or with many epochs, can be computationally intensive and require significant memory. Default parameters might not be optimized for all environments.
fix
Start with smaller datasets and fewer epochs to test your setup. Monitor resource usage (CPU/GPU, RAM) and consider optimizing hyperparameters or utilizing more powerful hardware for production-scale tasks.
affects: All
Errors
Common errors & fixes
ModuleNotFoundError: No module named 'decaf'
The library package name on PyPI is `decaf-synthetic-data`, but the primary import is `decaf`.
fix
Ensure you have installed the correct package: `pip install decaf-synthetic-data`.
ValueError: operands could not be broadcast together with shapes (X,) (Y,)
Input arrays (X, A, Y) passed to the `DECAF` model have incompatible shapes, often due to incorrect reshaping or concatenation.
fix
Verify that your input arrays have compatible dimensions. For example, `X` should typically be `(n_samples, n_features)`, while `A` and `Y` could be `(n_samples,)` or `(n_samples, 1)`.
AttributeError: 'DECAF' object has no attribute 'generate_synthetic_data'
You might be attempting to use a method that doesn't exist or is not available on the `DECAF` instance, possibly due to a typo or misunderstanding of the API.
fix
Check the official documentation or the `decaf/__init__.py` source code to confirm method names and their availability. The correct method to generate synthetic data from a trained model is `model.generate_synthetic_data()`.
Upgrade
Version history
0.1.7latest on PyPI · released Jun 16, 2025
Audit
Dependencies

No dependency data recorded yet.

Agent activity
22 hits · last 30 days
node
18
OpenAI (training)
1
Resources
decaf-synthetic-data — pip install decaf-synthetic-data · libregistry