axiom-effect / README.md
maxpagels's picture
Update model card
dfc0fa8 verified
|
Raw History Blame Contribute Delete
4.5 kB
---
library_name: axiom-effect
tags:
- causal-inference
- effect-estimation
- tabular
- pytorch
license: apache-2.0
---
# Axiom Effect
Causal effects from a table: what happens to an outcome when a treatment is *set* to one
value instead of another. For binary treatments the average effect (ATE), the effect on the
treated (ATT) and on the controls, and every row's own effect (CATE); for continuous ones the
effect between two values, the dose-response curve and every row's effect, each with 90% and
50% intervals. Trained on simulated data where every row's effect is known.
**Version 0.6.0 is experimental.** The API and the weights will change in 0.x releases.
Check its answers against what you know about your data.
It works without a causal graph, the usual assumption being that every covariate is measured
before the treatment, and better with one. It is the sibling of
[Axiom Discovery](https://huggingface.co/liminalplanes/axiom-discovery), the causal discovery model: given a
discovered graph, it reads each covariate's role (confounder, instrument, mediator, collider,
...) as probabilities, so a discovered graph helps it tell the columns that must be adjusted
for from the ones that would bias the answer.
20.3M parameters, fp32 safetensors (81 MB). Project page:
[liminalplanes.com/axiom](https://liminalplanes.com/axiom).
## Recommended use (ballpark)
| | recommendation |
|---|---|
| treatment | binary (two values) or continuous (at least 10 distinct values); continuous values inside its 2-98% quantiles |
| covariates | trained on up to 84; without a graph they must all be pre-treatment (not caused by the treatment) |
| graph | none; a DAG you trust (the treatment's descendants are then dropped); or an Axiom `discover()` result |
| rows | trained on 128-1536; larger tables are split into disjoint subsets of up to 1536 rows and combined |
| hidden confounders | not handled: no unmeasured common causes of the treatment and the outcome |
| missing values | not supported in the columns used |
## Usage
```bash
pip install "git+https://huggingface.co/liminalplanes/axiom-effect"
```
```python
from axiom_effect import AxiomEffect
model = AxiomEffect.from_pretrained("liminalplanes/axiom-effect")
r = model.effect(df, treatment="discount", outcome="spend") # no graph
print(r)
r.ate, r.att # (estimate, lo, hi), 90%
r.cate # every row's effect
r.debiased # binary: doubly robust (AIPW), the model's outcome predictions + a logistic propensity
```
With a graph:
```python
graph = [("age", "discount"), ("age", "spend"), ("discount", "visits"), ("visits", "spend")]
r = model.effect(df, "discount", "spend", graph=graph) # visits (a mediator) is not adjusted for
from axiom import Axiom
g = Axiom.from_pretrained("liminalplanes/axiom-discovery").discover(df)
r = model.effect(df, "discount", "spend", graph=g) # role probabilities from the discovered graph
r.roles # what the model was told about each covariate
```
A graph can be a list of (cause, effect) column names, a (d, d) adjacency matrix in the
table's column order, an adjacency DataFrame, or a `discover()` result. Continuous
treatments take `contrast=(a, b)` (default: the 25% and 75% quantiles), `values`
for the curve (default: the 10/25/50/75/90% quantiles) and `reference` (default: the median).
Everything is in the data's own units.
## Limitations
- No hidden confounders; identification by adjustment only.
- A DAG is taken as true; a discovered graph is read as probabilities, but it can still be
wrong in ways the probabilities do not show.
- Large, wide tables are split into row subsets (see above), and it is weaker on them than on
smaller ones.
- `r.debiased` is not reliably better than `r.ate`; it is there to compare against.
- Trained on simulated data; benchmarked on semi-synthetic data (IHDP, ACIC 2016) with real
covariates; no evaluation on real effects yet.
- The intervals are the model's own quantiles, trained to cover on its simulated data; how
well they cover elsewhere is not yet known.
## Versions
Each release is a tagged commit in this repo; `main` is the latest. The package loads the
weights released with it, so code and weights always match. To install a specific release,
an earlier one included, use its tag:
```bash
pip install "git+https://huggingface.co/liminalplanes/axiom-effect@v0.6.0" # or an earlier tag, e.g. @v0.1.0
```