File size: 10,699 Bytes
0056dba
11f3fff
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
<!doctype html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width,initial-scale=1">
<title>Causal Forge</title>
<style>
:root { color-scheme: dark; font-family: Inter, ui-sans-serif, system-ui; }
* { box-sizing: border-box; }
body { margin: 0; min-height: 100vh; background: #060817; color: #edf4ff; }
canvas { position: fixed; inset: 0; width: 100%; height: 100%; opacity: .55; }
main { position: relative; z-index: 1; width: min(1080px, 92vw); margin: auto;
  padding: 72px 0 96px; }
.eyebrow { color: #73e6ff; letter-spacing: .18em; text-transform: uppercase;
  font-size: .75rem; font-weight: 800; }
h1 { font-size: clamp(3rem, 8vw, 7rem); line-height: .9; margin: 14px 0 24px;
  background: linear-gradient(120deg,#fff,#74e7ff 55%,#b48cff);
  -webkit-background-clip: text; color: transparent; }
.lead { max-width: 760px; color: #b8c7e6; font-size: 1.2rem; line-height: 1.65; }
.actions { display: flex; flex-wrap: wrap; gap: 12px; margin: 30px 0 48px; }
a { color: inherit; }
.button { padding: 12px 18px; border-radius: 999px; text-decoration: none;
  background: #eaf8ff; color: #07101c; font-weight: 800; }
.button.alt { background: #171d38cc; color: #dce8ff; border: 1px solid #415078; }
.grid { display: grid; grid-template-columns: 1.1fr .9fr; gap: 20px; }
.card { border: 1px solid #344269; background: #0c1128dd; border-radius: 24px;
  padding: 24px; backdrop-filter: blur(18px); box-shadow: 0 24px 80px #0008; }
h2 { margin-top: 0; }
pre { white-space: pre-wrap; word-break: break-word; color: #a9bddf;
  max-height: 520px; overflow: auto; }
ul { max-height: 520px; overflow: auto; padding-left: 1.2rem; color: #a9bddf; }
li { margin: 8px 0; }
input { width: 100%; padding: 12px; border-radius: 12px; border: 1px solid #344269;
  background: #070b1a; color: white; margin-bottom: 12px; }
@media (max-width: 780px) { .grid { grid-template-columns: 1fr; } }
</style>
</head>
<body>
<canvas id="field"></canvas>
<main>
  <div class="eyebrow">Jacob Garcia · Hugging Face Model Foundry</div>
  <h1>Causal Forge</h1>
  <p class="lead">Interactive association-versus-causation laboratory. This showcase backs up the
  trained artifacts, measured evaluation, and complete runnable source.</p>
  <div class="actions">
    <a class="button" href="https://huggingface.co/spaces/ARotting/causal-forge/tree/main">Explore every file</a>
    <a class="button alt" href="https://huggingface.co/ARotting">View the full foundry</a>
  </div>
  <div class="grid">
    <section class="card">
      <h2>Verified project card</h2>
      <pre># Causal Forge

Causal Forge is a ground-truth causal inference laboratory. Its structural causal
model creates confounding, heterogeneous treatment effects, nonlinear outcomes, and
known counterfactuals. The benchmark measures whether estimators recover the
population average treatment effect rather than merely predicting observed outcomes.

The evaluation compares:

- the unadjusted difference in observed group means;
- inverse-propensity weighting (IPW);
- outcome regression with separate treatment/control response surfaces;
- the augmented IPW (AIPW) doubly robust estimator;
- four nuisance-model regimes where the propensity model, outcome model, both, or
  neither receive the correct nonlinear feature basis.

The exact potential outcomes and treatment probabilities are retained only because
this is a synthetic benchmark. They make estimator bias directly measurable.

## Verified results

The benchmark ran 100 independent replications with 3,000 observations and five-fold
cross-fitting in each replication.

| Nuisance-model regime | Naive MAE | IPW MAE | Outcome MAE | AIPW MAE | AIPW bias |
| --- | ---: | ---: | ---: | ---: | ---: |
| Both correct | 1.1109 | 0.0644 | 0.0388 | 0.0426 | 0.0004 |
| Propensity misspecified | 1.1109 | 0.1342 | 0.0388 | 0.0414 | 0.0008 |
| Outcome misspecified | 1.1109 | 0.0644 | 0.2688 | 0.0481 | 0.0078 |
| Both misspecified | 1.1109 | 0.1342 | 0.2688 | 0.3953 | 0.3953 |

This demonstrates the intended double-robustness boundary: AIPW remains accurate
when either the treatment or outcome nuisance model is correct, but not when both
are wrong. Results are Monte Carlo measurements on this synthetic SCM, not claims
about arbitrary real-world observational data.

## Reproduce

```powershell
uv run python projects/causal-forge/train.py
```
</pre>
      <h2>Evaluation snapshot</h2>
      <pre>{
  &quot;benchmark&quot;: &quot;Causal Forge&quot;,
  &quot;replications&quot;: 100,
  &quot;samples_per_replication&quot;: 3000,
  &quot;cross_fitting_folds&quot;: 5,
  &quot;structural_truth&quot;: &quot;known heterogeneous individual treatment effects&quot;,
  &quot;summary&quot;: {
    &quot;both_correct&quot;: {
      &quot;naive&quot;: {
        &quot;mean_estimate&quot;: 3.1123144027184075,
        &quot;bias&quot;: 1.110939263534936,
        &quot;mean_absolute_error&quot;: 1.110939263534936,
        &quot;rmse&quot;: 1.1132682867094192
      },
      &quot;ipw&quot;: {
        &quot;mean_estimate&quot;: 2.005159416540855,
        &quot;bias&quot;: 0.0037842773573832744,
        &quot;mean_absolute_error&quot;: 0.0643549025548575,
        &quot;rmse&quot;: 0.07985124612336089
      },
      &quot;outcome_regression&quot;: {
        &quot;mean_estimate&quot;: 2.0031127881794304,
        &quot;bias&quot;: 0.0017376489959579633,
        &quot;mean_absolute_error&quot;: 0.038795035337436425,
        &quot;rmse&quot;: 0.04801133697032812
      },
      &quot;aipw&quot;: {
        &quot;mean_estimate&quot;: 2.0017294974257873,
        &quot;bias&quot;: 0.00035435824231527135,
        &quot;mean_absolute_error&quot;: 0.04261334125461211,
        &quot;rmse&quot;: 0.05444966094807796,
        &quot;confidence_interval_coverage&quot;: 0.89
      }
    },
    &quot;propensity_misspecified&quot;: {
      &quot;naive&quot;: {
        &quot;mean_estimate&quot;: 3.1123144027184075,
        &quot;bias&quot;: 1.110939263534936,
        &quot;mean_absolute_error&quot;: 1.110939263534936,
        &quot;rmse&quot;: 1.1132682867094192
      },
      &quot;ipw&quot;: {
        &quot;mean_estimate&quot;: 2.1339948243616265,
        &quot;bias&quot;: 0.13261968517815434,
        &quot;mean_absolute_error&quot;: 0.1341636821632256,
        &quot;rmse&quot;: 0.14885056735045618
      },
      &quot;outcome_regression&quot;: {
        &quot;mean_estimate&quot;: 2.0031127881794304,
        &quot;bias&quot;: 0.0017376489959579633,
        &quot;mean_absolute_error&quot;: 0.038795035337436425,
        &quot;rmse&quot;: 0.04801133697032812
      },
      &quot;aipw&quot;: {
        &quot;mean_estimate&quot;: 2.002138366914246,
        &quot;bias&quot;: 0.0007632277307738455,
        &quot;mean_absolute_error&quot;: 0.04142272629021512,
        &quot;rmse&quot;: 0.05271409176654249,
        &quot;confidence_interval_coverage&quot;: 0.92
      }
    },
    &quot;outcome_misspecified&quot;: {
      &quot;naive&quot;: {
        &quot;mean_estimate&quot;: 3.1123144027184075,
        &quot;bias&quot;: 1.110939263534936,
        &quot;mean_absolute_error&quot;: 1.110939263534936,
        &quot;rmse&quot;: 1.1132682867094192
      },
      &quot;ipw&quot;: {
        &quot;mean_estimate&quot;: 2.005159416540855,
        &quot;bias&quot;: 0.0037842773573832744,
        &quot;mean_absolute_error&quot;: 0.0643549025548575,
        &quot;rmse&quot;: 0.07985124612336089
      },
      &quot;outcome_regression&quot;: {
        &quot;mean_estimate&quot;: 2.2701977886081592,
        &quot;bias&quot;: 0.26882264942468725,
        &quot;mean_absolute_error&quot;: 0.26882264942468725,
        &quot;rmse&quot;: 0.2753485792353652
      },
      &quot;aipw&quot;: {
        &quot;mean_estimate&quot;: 2.009154042503896,
        &quot;bias&quot;: 0.007778903320424111,
        &quot;mean_absolute_error&quot;: 0.048137374861682396,
        &quot;rmse&quot;: 0.06166591119979539,
        &quot;confidence_interval_coverage&quot;: 0.99
      }
    },
    &quot;both_misspecified&quot;: {
      &quot;naive&quot;: {
        &quot;mean_estimate&quot;: 3.1123144027184075,
        &quot;bias&quot;: 1.110939263534936,
        &quot;mean_absolute_error&quot;: 1.110939263534936,
        &quot;rmse&quot;: 1.1132682867094192
      },
      &quot;ipw&quot;: {
        &quot;mean_estimate&quot;: 2.1339948243616265,
        &quot;bias&quot;: 0.13261968517815434,
        &quot;mean_absolute_error&quot;: 0.1341636821632256,
        &quot;rmse&quot;: 0.14885056735045618
      },
      &quot;outcome_regression&quot;: {
        &quot;mean_estimate&quot;: 2.2701977886081592,
        &quot;bias&quot;: 0.26882264942468725,
        &quot;mean_absolute_error&quot;: 0.26882264942468725,
        &quot;rmse&quot;: 0.2753485792353652
      },
      &quot;aipw&quot;: {
        &quot;mean_estimate&quot;: 2.396631864687349,
        &quot;bias&quot;: 0.395256725503877,
        &quot;mean_absolute_error&quot;: 0.395256725503877,
        &quot;rmse&quot;: 0.4048953844650616,
        &quot;confidence_interval_coverage&quot;: 0.01
      }
    }
  }
}</pre>
    </section>
    <section class="card">
      <h2>Backed-up artifact tree</h2>
      <input id="filter" placeholder="Filter files…" autocomplete="off">
      <ul id="files"><li><code>README.md</code></li>
<li><code>__pycache__/app.cpython-311.pyc</code></li>
<li><code>__pycache__/causal.cpython-311.pyc</code></li>
<li><code>app.py</code></li>
<li><code>artifacts/causal-forge/evaluation.json</code></li>
<li><code>artifacts/causal-forge/nuisance_models.joblib</code></li>
<li><code>artifacts/causal-forge/replication_estimates.parquet</code></li>
<li><code>causal.py</code></li>
<li><code>data/causal_benchmark.parquet</code></li>
<li><code>requirements.txt</code></li>
<li><code>train.py</code></li></ul>
    </section>
  </div>
</main>
<script>
const canvas=document.querySelector('#field'),ctx=canvas.getContext('2d');
let dots=[];
function resize(){canvas.width=innerWidth;canvas.height=innerHeight;
dots=Array.from({length:90},()=>({x:Math.random()*innerWidth,
y:Math.random()*innerHeight,vx:(Math.random()-.5)*.35,vy:(Math.random()-.5)*.35}));}
function draw(){ctx.clearRect(0,0,canvas.width,canvas.height);
for(const d of dots){d.x=(d.x+d.vx+innerWidth)%innerWidth;
d.y=(d.y+d.vy+innerHeight)%innerHeight;ctx.fillStyle='#65dcff99';
ctx.beginPath();ctx.arc(d.x,d.y,1.4,0,7);ctx.fill();}requestAnimationFrame(draw);}
addEventListener('resize',resize);resize();draw();
document.querySelector('#filter').addEventListener('input',e=>{
const q=e.target.value.toLowerCase();for(const li of document.querySelectorAll('li'))
li.hidden=!li.textContent.toLowerCase().includes(q);});
</script>
</body>
</html>