Front-door CATE/ATE estimation toolkit with debiased learners.
Project description
FD-CATE
Front-door CATE/ATE estimation toolkit with paper-parity defaults for debiased front-door learners.
This repository keeps the original research scripts (FDCATE.py, analyze_fars_2000_fd.py) and adds a standard-library interface (fd_cate) with a stable artifact contract.
Install
python -m pip install -U pip
python -m pip install fd-cate
Default learner is xgb (XGBoost). nn is also supported via nuisance_learner="nn".
One-Click Quickstart (딸깍 1번)
fdcate demo --outdir ./fdcate-demo
This single command runs:
- synthetic data generation
- model fit + artifact contract write
- optional quick benchmark (enabled by default)
Expected files:
./fdcate-demo/synthetic.csv./fdcate-demo/fit_out/summary.txt./fdcate-demo/fit_out/results.json./fdcate-demo/fit_out/diagnostics.json./fdcate-demo/fit_out/effects.csv./fdcate-demo/fit_out/model.pkl./fdcate-demo/benchmark_quick.json(unless--run-benchmark false)
Quickstart (Python API)
from fd_cate import FDCATE
from FDCATE import simulate_fd_data_md
# synthetic example
D = simulate_fd_data_md(n=500, d=10, seed=0)
est = FDCATE(method="fd-dr", nuisance_learner="xgb", random_state=0)
est.fit(D.C, D.Y, t=D.X, m=D.Z)
tau = est.effect(D.C)
print(est.ate_)
print(est.summary())
Quickstart (CLI)
# generate synthetic csv
fdcate synthetic --n 300 --d 8 --seed 42 --out synthetic.csv
# fit + write standard artifacts
fdcate fit \
--data synthetic.csv \
--outcome y --treat t --med m \
--outdir out/
# diagnostics only
fdcate doctor \
--data synthetic.csv \
--outcome y --treat t --med m
Standard artifacts under out/:
summary.txtresults.jsondiagnostics.jsoneffects.csvmodel.pkl
Benchmark (Quick Profile + Golden Regression)
fd-cate now includes a deterministic quick benchmark profile for regression checks.
fdcate benchmark --n 120 --d 6 --seed 2026 --nuisance-learner xgb --out results/benchmark_quick.json
Multi-seed profile (recommended for robust comparisons):
fdcate benchmark \
--profile multiseed \
--n 120 --d 6 --seed 2026 --n-seeds 20 \
--nuisance-learner xgb \
--fd-r-g-solver direct \
--fd-r-b-learner xgb \
--out results/benchmark_multiseed.json
Output schema (fdcate.benchmark, schema_version=0) contains:
cleanRMSE forfd-pi,fd-dr,fd-rweak-overlapRMSE forfd-pi,fd-dr,fd-raggregate_mean_rmseacross the two scenarios- with
--profile multiseed:per_seedresults + summary statistics (mean/std/min/max)
FD-R benchmarking knobs:
--fd-r-g-solver:directorratio--fd-r-b-learner:xgbornn--no-fd-r-swap-average: disable swapped D1/D2 averaging
CI also runs a golden snapshot regression test:
tests/test_benchmark_golden.py- golden reference file:
tests/benchmark_quick_reference.json
Live Demo (Toy + Benchmark)
Primary path (CLI one-click):
fdcate demo --outdir /tmp/fdcate_live_demo
Secondary path (legacy helper script):
bash scripts/run_demo_quick.sh
The demo writes:
/tmp/fdcate_live_demo/fit_out/summary.txt/tmp/fdcate_live_demo/fit_out/results.json/tmp/fdcate_live_demo/fit_out/diagnostics.json/tmp/fdcate_live_demo/fit_out/effects.csv/tmp/fdcate_live_demo/fit_out/model.pkl/tmp/fdcate_live_demo/benchmark_quick.json
Manual one-liners:
fdcate synthetic --n 120 --d 6 --seed 2026 --out /tmp/fdcate_live_demo/synthetic.csv
fdcate fit --data /tmp/fdcate_live_demo/synthetic.csv --outcome y --treat t --med m --method fd-dr --nuisance-learner xgb --outdir /tmp/fdcate_live_demo/fit_out
fdcate benchmark --n 60 --d 4 --seed 17 --nuisance-learner xgb --out /tmp/fdcate_live_demo/benchmark_quick.json
Example terminal output preview (fdcate demo --outdir /tmp/fdcate_live_demo):
[demo] output directory: /tmp/fdcate_live_demo
[demo] ATE=0.540874
[demo] generated files:
- /tmp/fdcate_live_demo/synthetic.csv
- /tmp/fdcate_live_demo/fit_out/summary.txt
- /tmp/fdcate_live_demo/fit_out/results.json
- /tmp/fdcate_live_demo/fit_out/diagnostics.json
- /tmp/fdcate_live_demo/fit_out/effects.csv
- /tmp/fdcate_live_demo/fit_out/model.pkl
- /tmp/fdcate_live_demo/benchmark_quick.json
[demo] next: fdcate effect --model /tmp/fdcate_live_demo/fit_out/model.pkl --data /tmp/fdcate_live_demo/synthetic.csv --out /tmp/fdcate_live_demo/effects_from_model.csv
Final benchmark figures (FD-R full-noise setting):
Model Compatibility Policy (model.pkl)
model.pkl loading is allowed only when major.minor package versions match.
- Example: model saved with
0.1.xcan be loaded by0.1.y. - Example: model saved with
0.1.xcannot be loaded by0.2.x.
Scope (v0.1)
Supported:
- binary treatment
T ∈ {0,1} - binary mediator
M ∈ {0,1} - numeric covariates
- continuous or binary outcome (regression handling)
Not supported:
- non-binary
T/M - automatic categorical encoding pipelines
Legacy Reproduction Scripts
The original paper-focused scripts are preserved:
python FDCATE.py --helppython analyze_fars_2000_fd.py --help
Development
python -m pip install -e .[dev]
python -m pytest -q
python -m build
Nightly/manual slow tests are separated from PR fast gates:
python -m pytest -q -m "slow"
Release (v0.1.0)
bash scripts/release_preflight.sh
Detailed checklist: RELEASE_RUNBOOK.md
Troubleshooting
fdcate: command not found
- Re-open your shell after installation, or run with module form:
python -m fd_cate --help
- XGBoost import/runtime issue
- Reinstall in a clean environment:
python -m pip install -U pippython -m pip install --force-reinstall fd-cate
- Permission or write-path errors
- Use a writable output directory explicitly:
fdcate demo --outdir /tmp/fdcate-demo
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file fd_cate-0.1.0.tar.gz.
File metadata
- Download URL: fd_cate-0.1.0.tar.gz
- Upload date:
- Size: 41.0 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
4cc5d5caeba46822e8e970b22e88135fd695c8f7d09e6607fb894744b9bcadd8
|
|
| MD5 |
e465c0329bc75a20bbea78bc589c0c47
|
|
| BLAKE2b-256 |
3697e1b6d0a552955ad08fe0d62b59c4b2ac8a5e0f9b376ef25f3731b704972d
|
Provenance
The following attestation bundles were made for fd_cate-0.1.0.tar.gz:
Publisher:
release.yml on yonghanjung/FD-CATE
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
fd_cate-0.1.0.tar.gz -
Subject digest:
4cc5d5caeba46822e8e970b22e88135fd695c8f7d09e6607fb894744b9bcadd8 - Sigstore transparency entry: 1042781563
- Sigstore integration time:
-
Permalink:
yonghanjung/FD-CATE@a689a5b3aab28da0046701f9b5ddbd89f012fe03 -
Branch / Tag:
refs/tags/v0.1.0 - Owner: https://github.com/yonghanjung
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release.yml@a689a5b3aab28da0046701f9b5ddbd89f012fe03 -
Trigger Event:
push
-
Statement type:
File details
Details for the file fd_cate-0.1.0-py3-none-any.whl.
File metadata
- Download URL: fd_cate-0.1.0-py3-none-any.whl
- Upload date:
- Size: 39.7 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
b8473cd2a662b3ea5f99a2d530d6891e8b9bb44bcbca611c496116fde707d725
|
|
| MD5 |
b6e742341837ae55ce889e4721c780b1
|
|
| BLAKE2b-256 |
42091c576a6f63a6ee2d9e90db4a2d0ad0610db3b864ed7b9b358d11e5f4d999
|
Provenance
The following attestation bundles were made for fd_cate-0.1.0-py3-none-any.whl:
Publisher:
release.yml on yonghanjung/FD-CATE
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
fd_cate-0.1.0-py3-none-any.whl -
Subject digest:
b8473cd2a662b3ea5f99a2d530d6891e8b9bb44bcbca611c496116fde707d725 - Sigstore transparency entry: 1042781610
- Sigstore integration time:
-
Permalink:
yonghanjung/FD-CATE@a689a5b3aab28da0046701f9b5ddbd89f012fe03 -
Branch / Tag:
refs/tags/v0.1.0 - Owner: https://github.com/yonghanjung
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release.yml@a689a5b3aab28da0046701f9b5ddbd89f012fe03 -
Trigger Event:
push
-
Statement type: