@elaraai/east-py-datascience 1.0.4 → 1.0.5
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +10 -2
- package/dist/src/causal/causal.d.ts +1872 -0
- package/dist/src/causal/causal.d.ts.map +1 -0
- package/dist/src/causal/causal.js +593 -0
- package/dist/src/causal/causal.js.map +1 -0
- package/dist/src/index.d.ts +1 -0
- package/dist/src/index.d.ts.map +1 -1
- package/dist/src/index.js +2 -0
- package/dist/src/index.js.map +1 -1
- package/package.json +3 -3
|
@@ -0,0 +1,1872 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Copyright (c) 2025 Elara AI Pty Ltd
|
|
3
|
+
* Dual-licensed under AGPL-3.0 and commercial license. See LICENSE for details.
|
|
4
|
+
*/
|
|
5
|
+
/**
|
|
6
|
+
* Causal inference for East.
|
|
7
|
+
*
|
|
8
|
+
* Provides causal effect estimation (DoWhy backdoor adjustment),
|
|
9
|
+
* refutation tests, heterogeneous treatment effects (EconML LinearDML),
|
|
10
|
+
* and accumulated local effects dose-response curves (PyALE).
|
|
11
|
+
*
|
|
12
|
+
* @packageDocumentation
|
|
13
|
+
*/
|
|
14
|
+
import { StructType, VariantType, OptionType, ArrayType, IntegerType, FloatType, BooleanType, StringType, BlobType, NullType } from "@elaraai/east";
|
|
15
|
+
import { VectorType, MatrixType } from "../types.js";
|
|
16
|
+
export { VectorType, MatrixType } from "../types.js";
|
|
17
|
+
/**
|
|
18
|
+
* Inverse propensity weighting scheme for the propensity score
|
|
19
|
+
* weighting estimator.
|
|
20
|
+
*/
|
|
21
|
+
export declare const CausalWeightingSchemeType: VariantType<{
|
|
22
|
+
/** Raw inverse propensity weights */
|
|
23
|
+
readonly ips_weight: NullType;
|
|
24
|
+
/** Stabilized inverse propensity weights (recommended; lower variance) */
|
|
25
|
+
readonly ips_stabilized_weight: NullType;
|
|
26
|
+
/** Normalized inverse propensity weights */
|
|
27
|
+
readonly ips_normalized_weight: NullType;
|
|
28
|
+
}>;
|
|
29
|
+
/**
|
|
30
|
+
* Backdoor-adjusted effect estimator.
|
|
31
|
+
*/
|
|
32
|
+
export declare const CausalEstimatorType: VariantType<{
|
|
33
|
+
/** Linear regression of outcome on treatment + common causes */
|
|
34
|
+
readonly linear_regression: NullType;
|
|
35
|
+
/** Inverse propensity score weighting (binary treatment only) */
|
|
36
|
+
readonly propensity_score_weighting: StructType<{
|
|
37
|
+
/** Weighting scheme (default: ips_stabilized_weight) */
|
|
38
|
+
readonly weighting_scheme: OptionType<VariantType<{
|
|
39
|
+
/** Raw inverse propensity weights */
|
|
40
|
+
readonly ips_weight: NullType;
|
|
41
|
+
/** Stabilized inverse propensity weights (recommended; lower variance) */
|
|
42
|
+
readonly ips_stabilized_weight: NullType;
|
|
43
|
+
/** Normalized inverse propensity weights */
|
|
44
|
+
readonly ips_normalized_weight: NullType;
|
|
45
|
+
}>>;
|
|
46
|
+
}>;
|
|
47
|
+
}>;
|
|
48
|
+
/**
|
|
49
|
+
* Population the effect is estimated for.
|
|
50
|
+
*/
|
|
51
|
+
export declare const CausalTargetUnitsType: VariantType<{
|
|
52
|
+
/** Average treatment effect over all units */
|
|
53
|
+
readonly ate: NullType;
|
|
54
|
+
/** Average treatment effect on the treated */
|
|
55
|
+
readonly att: NullType;
|
|
56
|
+
/** Average treatment effect on the controls */
|
|
57
|
+
readonly atc: NullType;
|
|
58
|
+
}>;
|
|
59
|
+
/**
|
|
60
|
+
* Propensity-based sample trimming applied before estimation
|
|
61
|
+
* (propensity score weighting only).
|
|
62
|
+
*/
|
|
63
|
+
export declare const PropensityTrimType: VariantType<{
|
|
64
|
+
/** Keep units inside the common-support overlap of treated and control propensities */
|
|
65
|
+
readonly overlap: NullType;
|
|
66
|
+
/** Keep units with propensity inside explicit bounds */
|
|
67
|
+
readonly bounds: StructType<{
|
|
68
|
+
/** Minimum propensity score to keep */
|
|
69
|
+
readonly lower: FloatType;
|
|
70
|
+
/** Maximum propensity score to keep */
|
|
71
|
+
readonly upper: FloatType;
|
|
72
|
+
}>;
|
|
73
|
+
}>;
|
|
74
|
+
/**
|
|
75
|
+
* Bootstrap confidence interval configuration.
|
|
76
|
+
*
|
|
77
|
+
* When `cluster_column` is set, whole clusters are resampled with
|
|
78
|
+
* replacement (the cluster is the exchangeable unit) — use this when rows
|
|
79
|
+
* are autocorrelated within a group (e.g. days within a batch).
|
|
80
|
+
*/
|
|
81
|
+
export declare const CausalBootstrapConfigType: StructType<{
|
|
82
|
+
/** Number of bootstrap replicates */
|
|
83
|
+
readonly reps: IntegerType;
|
|
84
|
+
/** Column whose values identify clusters to resample (default: resample rows) */
|
|
85
|
+
readonly cluster_column: OptionType<StringType>;
|
|
86
|
+
/** Confidence level for the percentile interval (default 0.95) */
|
|
87
|
+
readonly confidence_level: OptionType<FloatType>;
|
|
88
|
+
}>;
|
|
89
|
+
/**
|
|
90
|
+
* Configuration for backdoor-adjusted causal effect estimation.
|
|
91
|
+
*
|
|
92
|
+
* The data matrix is interpreted via `columns`: every column referenced by
|
|
93
|
+
* `treatment`, `outcome`, `common_causes`, `categorical` and
|
|
94
|
+
* `bootstrap.cluster_column` must appear in `columns`. Categorical columns
|
|
95
|
+
* hold integer-valued category codes and are one-hot encoded internally.
|
|
96
|
+
*/
|
|
97
|
+
export declare const CausalEffectConfigType: StructType<{
|
|
98
|
+
/** Column names for the data matrix (one per column, in order) */
|
|
99
|
+
readonly columns: ArrayType<StringType>;
|
|
100
|
+
/** Treatment column (must be 0/1 for propensity score weighting) */
|
|
101
|
+
readonly treatment: StringType;
|
|
102
|
+
/** Outcome column */
|
|
103
|
+
readonly outcome: StringType;
|
|
104
|
+
/** Confounder columns to adjust for (the backdoor set) */
|
|
105
|
+
readonly common_causes: ArrayType<StringType>;
|
|
106
|
+
/** Columns holding integer category codes, one-hot encoded internally */
|
|
107
|
+
readonly categorical: OptionType<ArrayType<StringType>>;
|
|
108
|
+
/** Effect estimator (default: linear_regression) */
|
|
109
|
+
readonly method: OptionType<VariantType<{
|
|
110
|
+
/** Linear regression of outcome on treatment + common causes */
|
|
111
|
+
readonly linear_regression: NullType;
|
|
112
|
+
/** Inverse propensity score weighting (binary treatment only) */
|
|
113
|
+
readonly propensity_score_weighting: StructType<{
|
|
114
|
+
/** Weighting scheme (default: ips_stabilized_weight) */
|
|
115
|
+
readonly weighting_scheme: OptionType<VariantType<{
|
|
116
|
+
/** Raw inverse propensity weights */
|
|
117
|
+
readonly ips_weight: NullType;
|
|
118
|
+
/** Stabilized inverse propensity weights (recommended; lower variance) */
|
|
119
|
+
readonly ips_stabilized_weight: NullType;
|
|
120
|
+
/** Normalized inverse propensity weights */
|
|
121
|
+
readonly ips_normalized_weight: NullType;
|
|
122
|
+
}>>;
|
|
123
|
+
}>;
|
|
124
|
+
}>>;
|
|
125
|
+
/** Target population (default: ate) */
|
|
126
|
+
readonly target_units: OptionType<VariantType<{
|
|
127
|
+
/** Average treatment effect over all units */
|
|
128
|
+
readonly ate: NullType;
|
|
129
|
+
/** Average treatment effect on the treated */
|
|
130
|
+
readonly att: NullType;
|
|
131
|
+
/** Average treatment effect on the controls */
|
|
132
|
+
readonly atc: NullType;
|
|
133
|
+
}>>;
|
|
134
|
+
/** Propensity trimming applied before estimation (psw only) */
|
|
135
|
+
readonly trim: OptionType<VariantType<{
|
|
136
|
+
/** Keep units inside the common-support overlap of treated and control propensities */
|
|
137
|
+
readonly overlap: NullType;
|
|
138
|
+
/** Keep units with propensity inside explicit bounds */
|
|
139
|
+
readonly bounds: StructType<{
|
|
140
|
+
/** Minimum propensity score to keep */
|
|
141
|
+
readonly lower: FloatType;
|
|
142
|
+
/** Maximum propensity score to keep */
|
|
143
|
+
readonly upper: FloatType;
|
|
144
|
+
}>;
|
|
145
|
+
}>>;
|
|
146
|
+
/** Bootstrap confidence interval (omit to skip CI computation) */
|
|
147
|
+
readonly bootstrap: OptionType<StructType<{
|
|
148
|
+
/** Number of bootstrap replicates */
|
|
149
|
+
readonly reps: IntegerType;
|
|
150
|
+
/** Column whose values identify clusters to resample (default: resample rows) */
|
|
151
|
+
readonly cluster_column: OptionType<StringType>;
|
|
152
|
+
/** Confidence level for the percentile interval (default 0.95) */
|
|
153
|
+
readonly confidence_level: OptionType<FloatType>;
|
|
154
|
+
}>>;
|
|
155
|
+
/** Random seed for propensity fitting and bootstrap resampling */
|
|
156
|
+
readonly random_state: OptionType<IntegerType>;
|
|
157
|
+
}>;
|
|
158
|
+
/**
|
|
159
|
+
* Refutation test for an estimated causal effect.
|
|
160
|
+
*/
|
|
161
|
+
export declare const CausalRefuterType: VariantType<{
|
|
162
|
+
/** Replace treatment with a permuted placebo - effect should vanish */
|
|
163
|
+
readonly placebo_treatment: StructType<{
|
|
164
|
+
/** Number of simulations (default 100) */
|
|
165
|
+
readonly num_simulations: OptionType<IntegerType>;
|
|
166
|
+
}>;
|
|
167
|
+
/** Add an independent random common cause - effect should be unchanged */
|
|
168
|
+
readonly random_common_cause: StructType<{
|
|
169
|
+
/** Number of simulations (default 100) */
|
|
170
|
+
readonly num_simulations: OptionType<IntegerType>;
|
|
171
|
+
}>;
|
|
172
|
+
/** Re-estimate on random data subsets - effect should be stable */
|
|
173
|
+
readonly data_subset: StructType<{
|
|
174
|
+
/** Fraction of rows kept per simulation (default 0.8) */
|
|
175
|
+
readonly subset_fraction: OptionType<FloatType>;
|
|
176
|
+
/** Number of simulations (default 100) */
|
|
177
|
+
readonly num_simulations: OptionType<IntegerType>;
|
|
178
|
+
}>;
|
|
179
|
+
/**
|
|
180
|
+
* Simulate an unobserved confounder at each given strength - a
|
|
181
|
+
* sensitivity/tipping curve. Strength acts on both treatment
|
|
182
|
+
* (flip probability for binary treatment, linear coefficient otherwise)
|
|
183
|
+
* and outcome (linear coefficient).
|
|
184
|
+
*/
|
|
185
|
+
readonly unobserved_common_cause: StructType<{
|
|
186
|
+
/** Confounder effect strengths to simulate, one new effect per entry */
|
|
187
|
+
readonly effect_strengths: ArrayType<FloatType>;
|
|
188
|
+
}>;
|
|
189
|
+
}>;
|
|
190
|
+
/**
|
|
191
|
+
* Nuisance model for DML residualization stages.
|
|
192
|
+
*/
|
|
193
|
+
export declare const CausalNuisanceModelType: VariantType<{
|
|
194
|
+
/** Random forest (regressor, or classifier for a discrete treatment) */
|
|
195
|
+
readonly random_forest: StructType<{
|
|
196
|
+
/** Number of trees (default 100) */
|
|
197
|
+
readonly n_estimators: OptionType<IntegerType>;
|
|
198
|
+
/** Minimum samples per leaf (default 5) */
|
|
199
|
+
readonly min_samples_leaf: OptionType<IntegerType>;
|
|
200
|
+
/** Maximum tree depth (default unlimited) */
|
|
201
|
+
readonly max_depth: OptionType<IntegerType>;
|
|
202
|
+
}>;
|
|
203
|
+
/** Gradient boosting (regressor, or classifier for a discrete treatment) */
|
|
204
|
+
readonly gradient_boosting: StructType<{
|
|
205
|
+
/** Number of boosting stages (default 100) */
|
|
206
|
+
readonly n_estimators: OptionType<IntegerType>;
|
|
207
|
+
/** Learning rate (default 0.1) */
|
|
208
|
+
readonly learning_rate: OptionType<FloatType>;
|
|
209
|
+
/** Maximum tree depth (default 3) */
|
|
210
|
+
readonly max_depth: OptionType<IntegerType>;
|
|
211
|
+
}>;
|
|
212
|
+
/** Linear/logistic regression */
|
|
213
|
+
readonly linear: NullType;
|
|
214
|
+
}>;
|
|
215
|
+
/**
|
|
216
|
+
* Configuration for double machine learning (EconML LinearDML).
|
|
217
|
+
*/
|
|
218
|
+
export declare const CausalDMLConfigType: StructType<{
|
|
219
|
+
/** Nuisance model for the outcome stage (default: random_forest) */
|
|
220
|
+
readonly model_y: OptionType<VariantType<{
|
|
221
|
+
/** Random forest (regressor, or classifier for a discrete treatment) */
|
|
222
|
+
readonly random_forest: StructType<{
|
|
223
|
+
/** Number of trees (default 100) */
|
|
224
|
+
readonly n_estimators: OptionType<IntegerType>;
|
|
225
|
+
/** Minimum samples per leaf (default 5) */
|
|
226
|
+
readonly min_samples_leaf: OptionType<IntegerType>;
|
|
227
|
+
/** Maximum tree depth (default unlimited) */
|
|
228
|
+
readonly max_depth: OptionType<IntegerType>;
|
|
229
|
+
}>;
|
|
230
|
+
/** Gradient boosting (regressor, or classifier for a discrete treatment) */
|
|
231
|
+
readonly gradient_boosting: StructType<{
|
|
232
|
+
/** Number of boosting stages (default 100) */
|
|
233
|
+
readonly n_estimators: OptionType<IntegerType>;
|
|
234
|
+
/** Learning rate (default 0.1) */
|
|
235
|
+
readonly learning_rate: OptionType<FloatType>;
|
|
236
|
+
/** Maximum tree depth (default 3) */
|
|
237
|
+
readonly max_depth: OptionType<IntegerType>;
|
|
238
|
+
}>;
|
|
239
|
+
/** Linear/logistic regression */
|
|
240
|
+
readonly linear: NullType;
|
|
241
|
+
}>>;
|
|
242
|
+
/** Nuisance model for the treatment stage (default: random_forest) */
|
|
243
|
+
readonly model_t: OptionType<VariantType<{
|
|
244
|
+
/** Random forest (regressor, or classifier for a discrete treatment) */
|
|
245
|
+
readonly random_forest: StructType<{
|
|
246
|
+
/** Number of trees (default 100) */
|
|
247
|
+
readonly n_estimators: OptionType<IntegerType>;
|
|
248
|
+
/** Minimum samples per leaf (default 5) */
|
|
249
|
+
readonly min_samples_leaf: OptionType<IntegerType>;
|
|
250
|
+
/** Maximum tree depth (default unlimited) */
|
|
251
|
+
readonly max_depth: OptionType<IntegerType>;
|
|
252
|
+
}>;
|
|
253
|
+
/** Gradient boosting (regressor, or classifier for a discrete treatment) */
|
|
254
|
+
readonly gradient_boosting: StructType<{
|
|
255
|
+
/** Number of boosting stages (default 100) */
|
|
256
|
+
readonly n_estimators: OptionType<IntegerType>;
|
|
257
|
+
/** Learning rate (default 0.1) */
|
|
258
|
+
readonly learning_rate: OptionType<FloatType>;
|
|
259
|
+
/** Maximum tree depth (default 3) */
|
|
260
|
+
readonly max_depth: OptionType<IntegerType>;
|
|
261
|
+
}>;
|
|
262
|
+
/** Linear/logistic regression */
|
|
263
|
+
readonly linear: NullType;
|
|
264
|
+
}>>;
|
|
265
|
+
/** Treat the treatment as discrete/categorical (default false) */
|
|
266
|
+
readonly discrete_treatment: OptionType<BooleanType>;
|
|
267
|
+
/** Cross-fitting folds (default 2) */
|
|
268
|
+
readonly cv_folds: OptionType<IntegerType>;
|
|
269
|
+
/** Confidence level for effect/ATE intervals (default 0.95) */
|
|
270
|
+
readonly confidence_level: OptionType<FloatType>;
|
|
271
|
+
/** Random seed */
|
|
272
|
+
readonly random_state: OptionType<IntegerType>;
|
|
273
|
+
}>;
|
|
274
|
+
/**
|
|
275
|
+
* Configuration for an accumulated local effects (ALE) dose-response curve.
|
|
276
|
+
*
|
|
277
|
+
* Fits a gradient-boosting emulator of the outcome on all non-outcome
|
|
278
|
+
* columns, then computes the correlation-robust ALE curve of `feature`.
|
|
279
|
+
*/
|
|
280
|
+
export declare const CausalALEConfigType: StructType<{
|
|
281
|
+
/** Column names for the data matrix (one per column, in order) */
|
|
282
|
+
readonly columns: ArrayType<StringType>;
|
|
283
|
+
/** Outcome column the emulator predicts */
|
|
284
|
+
readonly outcome: StringType;
|
|
285
|
+
/** Continuous feature column to compute the ALE curve for */
|
|
286
|
+
readonly feature: StringType;
|
|
287
|
+
/** Columns holding integer category codes, one-hot encoded internally */
|
|
288
|
+
readonly categorical: OptionType<ArrayType<StringType>>;
|
|
289
|
+
/** Number of grid intervals (default 10) */
|
|
290
|
+
readonly grid_size: OptionType<IntegerType>;
|
|
291
|
+
/** Include confidence intervals (default true) */
|
|
292
|
+
readonly include_ci: OptionType<BooleanType>;
|
|
293
|
+
/** Confidence level for the CI (default 0.95) */
|
|
294
|
+
readonly confidence_level: OptionType<FloatType>;
|
|
295
|
+
/** Emulator (HistGradientBoosting) hyperparameters */
|
|
296
|
+
readonly emulator: OptionType<StructType<{
|
|
297
|
+
/** Number of boosting iterations (default 300) */
|
|
298
|
+
readonly n_estimators: OptionType<IntegerType>;
|
|
299
|
+
/** Learning rate (default 0.05) */
|
|
300
|
+
readonly learning_rate: OptionType<FloatType>;
|
|
301
|
+
/** Maximum tree depth (default unlimited) */
|
|
302
|
+
readonly max_depth: OptionType<IntegerType>;
|
|
303
|
+
/** Minimum samples per leaf (default 20; lower for small datasets) */
|
|
304
|
+
readonly min_samples_leaf: OptionType<IntegerType>;
|
|
305
|
+
}>>;
|
|
306
|
+
/** Random seed for the emulator */
|
|
307
|
+
readonly random_state: OptionType<IntegerType>;
|
|
308
|
+
}>;
|
|
309
|
+
/**
|
|
310
|
+
* Model blob for a fitted LinearDML estimator.
|
|
311
|
+
*/
|
|
312
|
+
export declare const CausalDMLModelBlobType: VariantType<{
|
|
313
|
+
/** Fitted EconML LinearDML estimator */
|
|
314
|
+
readonly causal_dml: StructType<{
|
|
315
|
+
/** Serialized estimator (cloudpickle) */
|
|
316
|
+
readonly data: BlobType;
|
|
317
|
+
/** Number of effect-modifier (X) features */
|
|
318
|
+
readonly n_features_x: IntegerType;
|
|
319
|
+
/** Confidence level used for effect/ATE intervals */
|
|
320
|
+
readonly confidence_level: FloatType;
|
|
321
|
+
}>;
|
|
322
|
+
}>;
|
|
323
|
+
/**
|
|
324
|
+
* Estimated causal effect.
|
|
325
|
+
*/
|
|
326
|
+
export declare const CausalEffectResultType: StructType<{
|
|
327
|
+
/** Point estimate of the effect (outcome units per treatment unit) */
|
|
328
|
+
readonly effect: FloatType;
|
|
329
|
+
/** Bootstrap percentile confidence interval (present when bootstrap configured) */
|
|
330
|
+
readonly ci: OptionType<StructType<{
|
|
331
|
+
/** Lower bound */
|
|
332
|
+
readonly lower: FloatType;
|
|
333
|
+
/** Upper bound */
|
|
334
|
+
readonly upper: FloatType;
|
|
335
|
+
}>>;
|
|
336
|
+
/** Rows used for estimation (after trimming) */
|
|
337
|
+
readonly n_samples: IntegerType;
|
|
338
|
+
/** Treated rows used */
|
|
339
|
+
readonly n_treated: IntegerType;
|
|
340
|
+
/** Control rows used */
|
|
341
|
+
readonly n_control: IntegerType;
|
|
342
|
+
}>;
|
|
343
|
+
/**
|
|
344
|
+
* Refutation test result.
|
|
345
|
+
*/
|
|
346
|
+
export declare const CausalRefuteResultType: StructType<{
|
|
347
|
+
/** The original estimated effect being refuted */
|
|
348
|
+
readonly estimated_effect: FloatType;
|
|
349
|
+
/**
|
|
350
|
+
* Effect under the refutation. One entry for placebo/random-common-cause/
|
|
351
|
+
* data-subset; one entry per strength for unobserved_common_cause.
|
|
352
|
+
*/
|
|
353
|
+
readonly new_effects: VectorType<FloatType>;
|
|
354
|
+
/** Refutation p-value where the refuter provides one */
|
|
355
|
+
readonly p_value: OptionType<FloatType>;
|
|
356
|
+
}>;
|
|
357
|
+
/**
|
|
358
|
+
* Average treatment effect with confidence interval.
|
|
359
|
+
*/
|
|
360
|
+
export declare const CausalATEResultType: StructType<{
|
|
361
|
+
/** Average treatment effect over the given X */
|
|
362
|
+
readonly ate: FloatType;
|
|
363
|
+
/** Lower bound at the model's confidence level */
|
|
364
|
+
readonly lower: FloatType;
|
|
365
|
+
/** Upper bound at the model's confidence level */
|
|
366
|
+
readonly upper: FloatType;
|
|
367
|
+
}>;
|
|
368
|
+
/**
|
|
369
|
+
* Accumulated local effects curve.
|
|
370
|
+
*/
|
|
371
|
+
export declare const ALEResultType: StructType<{
|
|
372
|
+
/** Feature grid values (interval edges) */
|
|
373
|
+
readonly grid: VectorType<FloatType>;
|
|
374
|
+
/** Centered ALE effect at each grid value (outcome units) */
|
|
375
|
+
readonly effect: VectorType<FloatType>;
|
|
376
|
+
/** Lower CI at each grid value (present when include_ci) */
|
|
377
|
+
readonly lower: OptionType<VectorType<FloatType>>;
|
|
378
|
+
/** Upper CI at each grid value (present when include_ci) */
|
|
379
|
+
readonly upper: OptionType<VectorType<FloatType>>;
|
|
380
|
+
/** Number of samples in each grid interval */
|
|
381
|
+
readonly size: VectorType<IntegerType>;
|
|
382
|
+
}>;
|
|
383
|
+
/**
|
|
384
|
+
* Estimate a backdoor-adjusted causal effect of treatment on outcome.
|
|
385
|
+
*
|
|
386
|
+
* Identifies the effect with DoWhy given the common causes, then estimates
|
|
387
|
+
* it by linear regression or inverse propensity score weighting. Optionally
|
|
388
|
+
* trims to propensity common support and computes a (cluster) bootstrap
|
|
389
|
+
* confidence interval.
|
|
390
|
+
*
|
|
391
|
+
* @param data - Data matrix (rows = units, columns named by config.columns)
|
|
392
|
+
* @param config - Estimation configuration
|
|
393
|
+
* @returns Effect estimate with optional CI and sample counts
|
|
394
|
+
*/
|
|
395
|
+
export declare const causal_effect: import("@elaraai/east").PlatformDefinition<[MatrixType<FloatType>, StructType<{
|
|
396
|
+
/** Column names for the data matrix (one per column, in order) */
|
|
397
|
+
readonly columns: ArrayType<StringType>;
|
|
398
|
+
/** Treatment column (must be 0/1 for propensity score weighting) */
|
|
399
|
+
readonly treatment: StringType;
|
|
400
|
+
/** Outcome column */
|
|
401
|
+
readonly outcome: StringType;
|
|
402
|
+
/** Confounder columns to adjust for (the backdoor set) */
|
|
403
|
+
readonly common_causes: ArrayType<StringType>;
|
|
404
|
+
/** Columns holding integer category codes, one-hot encoded internally */
|
|
405
|
+
readonly categorical: OptionType<ArrayType<StringType>>;
|
|
406
|
+
/** Effect estimator (default: linear_regression) */
|
|
407
|
+
readonly method: OptionType<VariantType<{
|
|
408
|
+
/** Linear regression of outcome on treatment + common causes */
|
|
409
|
+
readonly linear_regression: NullType;
|
|
410
|
+
/** Inverse propensity score weighting (binary treatment only) */
|
|
411
|
+
readonly propensity_score_weighting: StructType<{
|
|
412
|
+
/** Weighting scheme (default: ips_stabilized_weight) */
|
|
413
|
+
readonly weighting_scheme: OptionType<VariantType<{
|
|
414
|
+
/** Raw inverse propensity weights */
|
|
415
|
+
readonly ips_weight: NullType;
|
|
416
|
+
/** Stabilized inverse propensity weights (recommended; lower variance) */
|
|
417
|
+
readonly ips_stabilized_weight: NullType;
|
|
418
|
+
/** Normalized inverse propensity weights */
|
|
419
|
+
readonly ips_normalized_weight: NullType;
|
|
420
|
+
}>>;
|
|
421
|
+
}>;
|
|
422
|
+
}>>;
|
|
423
|
+
/** Target population (default: ate) */
|
|
424
|
+
readonly target_units: OptionType<VariantType<{
|
|
425
|
+
/** Average treatment effect over all units */
|
|
426
|
+
readonly ate: NullType;
|
|
427
|
+
/** Average treatment effect on the treated */
|
|
428
|
+
readonly att: NullType;
|
|
429
|
+
/** Average treatment effect on the controls */
|
|
430
|
+
readonly atc: NullType;
|
|
431
|
+
}>>;
|
|
432
|
+
/** Propensity trimming applied before estimation (psw only) */
|
|
433
|
+
readonly trim: OptionType<VariantType<{
|
|
434
|
+
/** Keep units inside the common-support overlap of treated and control propensities */
|
|
435
|
+
readonly overlap: NullType;
|
|
436
|
+
/** Keep units with propensity inside explicit bounds */
|
|
437
|
+
readonly bounds: StructType<{
|
|
438
|
+
/** Minimum propensity score to keep */
|
|
439
|
+
readonly lower: FloatType;
|
|
440
|
+
/** Maximum propensity score to keep */
|
|
441
|
+
readonly upper: FloatType;
|
|
442
|
+
}>;
|
|
443
|
+
}>>;
|
|
444
|
+
/** Bootstrap confidence interval (omit to skip CI computation) */
|
|
445
|
+
readonly bootstrap: OptionType<StructType<{
|
|
446
|
+
/** Number of bootstrap replicates */
|
|
447
|
+
readonly reps: IntegerType;
|
|
448
|
+
/** Column whose values identify clusters to resample (default: resample rows) */
|
|
449
|
+
readonly cluster_column: OptionType<StringType>;
|
|
450
|
+
/** Confidence level for the percentile interval (default 0.95) */
|
|
451
|
+
readonly confidence_level: OptionType<FloatType>;
|
|
452
|
+
}>>;
|
|
453
|
+
/** Random seed for propensity fitting and bootstrap resampling */
|
|
454
|
+
readonly random_state: OptionType<IntegerType>;
|
|
455
|
+
}>], StructType<{
|
|
456
|
+
/** Point estimate of the effect (outcome units per treatment unit) */
|
|
457
|
+
readonly effect: FloatType;
|
|
458
|
+
/** Bootstrap percentile confidence interval (present when bootstrap configured) */
|
|
459
|
+
readonly ci: OptionType<StructType<{
|
|
460
|
+
/** Lower bound */
|
|
461
|
+
readonly lower: FloatType;
|
|
462
|
+
/** Upper bound */
|
|
463
|
+
readonly upper: FloatType;
|
|
464
|
+
}>>;
|
|
465
|
+
/** Rows used for estimation (after trimming) */
|
|
466
|
+
readonly n_samples: IntegerType;
|
|
467
|
+
/** Treated rows used */
|
|
468
|
+
readonly n_treated: IntegerType;
|
|
469
|
+
/** Control rows used */
|
|
470
|
+
readonly n_control: IntegerType;
|
|
471
|
+
}>>;
|
|
472
|
+
/**
|
|
473
|
+
* Refute an estimated causal effect.
|
|
474
|
+
*
|
|
475
|
+
* Re-estimates the effect from `config`, then applies the given refuter
|
|
476
|
+
* (placebo treatment, random common cause, data subset, or simulated
|
|
477
|
+
* unobserved confounder sensitivity curve).
|
|
478
|
+
*
|
|
479
|
+
* @param data - Data matrix (rows = units, columns named by config.columns)
|
|
480
|
+
* @param config - Estimation configuration (same as causal_effect)
|
|
481
|
+
* @param refuter - Refutation test to apply
|
|
482
|
+
* @returns Original effect, refuted effect(s), and p-value where available
|
|
483
|
+
*/
|
|
484
|
+
export declare const causal_refute: import("@elaraai/east").PlatformDefinition<[MatrixType<FloatType>, StructType<{
|
|
485
|
+
/** Column names for the data matrix (one per column, in order) */
|
|
486
|
+
readonly columns: ArrayType<StringType>;
|
|
487
|
+
/** Treatment column (must be 0/1 for propensity score weighting) */
|
|
488
|
+
readonly treatment: StringType;
|
|
489
|
+
/** Outcome column */
|
|
490
|
+
readonly outcome: StringType;
|
|
491
|
+
/** Confounder columns to adjust for (the backdoor set) */
|
|
492
|
+
readonly common_causes: ArrayType<StringType>;
|
|
493
|
+
/** Columns holding integer category codes, one-hot encoded internally */
|
|
494
|
+
readonly categorical: OptionType<ArrayType<StringType>>;
|
|
495
|
+
/** Effect estimator (default: linear_regression) */
|
|
496
|
+
readonly method: OptionType<VariantType<{
|
|
497
|
+
/** Linear regression of outcome on treatment + common causes */
|
|
498
|
+
readonly linear_regression: NullType;
|
|
499
|
+
/** Inverse propensity score weighting (binary treatment only) */
|
|
500
|
+
readonly propensity_score_weighting: StructType<{
|
|
501
|
+
/** Weighting scheme (default: ips_stabilized_weight) */
|
|
502
|
+
readonly weighting_scheme: OptionType<VariantType<{
|
|
503
|
+
/** Raw inverse propensity weights */
|
|
504
|
+
readonly ips_weight: NullType;
|
|
505
|
+
/** Stabilized inverse propensity weights (recommended; lower variance) */
|
|
506
|
+
readonly ips_stabilized_weight: NullType;
|
|
507
|
+
/** Normalized inverse propensity weights */
|
|
508
|
+
readonly ips_normalized_weight: NullType;
|
|
509
|
+
}>>;
|
|
510
|
+
}>;
|
|
511
|
+
}>>;
|
|
512
|
+
/** Target population (default: ate) */
|
|
513
|
+
readonly target_units: OptionType<VariantType<{
|
|
514
|
+
/** Average treatment effect over all units */
|
|
515
|
+
readonly ate: NullType;
|
|
516
|
+
/** Average treatment effect on the treated */
|
|
517
|
+
readonly att: NullType;
|
|
518
|
+
/** Average treatment effect on the controls */
|
|
519
|
+
readonly atc: NullType;
|
|
520
|
+
}>>;
|
|
521
|
+
/** Propensity trimming applied before estimation (psw only) */
|
|
522
|
+
readonly trim: OptionType<VariantType<{
|
|
523
|
+
/** Keep units inside the common-support overlap of treated and control propensities */
|
|
524
|
+
readonly overlap: NullType;
|
|
525
|
+
/** Keep units with propensity inside explicit bounds */
|
|
526
|
+
readonly bounds: StructType<{
|
|
527
|
+
/** Minimum propensity score to keep */
|
|
528
|
+
readonly lower: FloatType;
|
|
529
|
+
/** Maximum propensity score to keep */
|
|
530
|
+
readonly upper: FloatType;
|
|
531
|
+
}>;
|
|
532
|
+
}>>;
|
|
533
|
+
/** Bootstrap confidence interval (omit to skip CI computation) */
|
|
534
|
+
readonly bootstrap: OptionType<StructType<{
|
|
535
|
+
/** Number of bootstrap replicates */
|
|
536
|
+
readonly reps: IntegerType;
|
|
537
|
+
/** Column whose values identify clusters to resample (default: resample rows) */
|
|
538
|
+
readonly cluster_column: OptionType<StringType>;
|
|
539
|
+
/** Confidence level for the percentile interval (default 0.95) */
|
|
540
|
+
readonly confidence_level: OptionType<FloatType>;
|
|
541
|
+
}>>;
|
|
542
|
+
/** Random seed for propensity fitting and bootstrap resampling */
|
|
543
|
+
readonly random_state: OptionType<IntegerType>;
|
|
544
|
+
}>, VariantType<{
|
|
545
|
+
/** Replace treatment with a permuted placebo - effect should vanish */
|
|
546
|
+
readonly placebo_treatment: StructType<{
|
|
547
|
+
/** Number of simulations (default 100) */
|
|
548
|
+
readonly num_simulations: OptionType<IntegerType>;
|
|
549
|
+
}>;
|
|
550
|
+
/** Add an independent random common cause - effect should be unchanged */
|
|
551
|
+
readonly random_common_cause: StructType<{
|
|
552
|
+
/** Number of simulations (default 100) */
|
|
553
|
+
readonly num_simulations: OptionType<IntegerType>;
|
|
554
|
+
}>;
|
|
555
|
+
/** Re-estimate on random data subsets - effect should be stable */
|
|
556
|
+
readonly data_subset: StructType<{
|
|
557
|
+
/** Fraction of rows kept per simulation (default 0.8) */
|
|
558
|
+
readonly subset_fraction: OptionType<FloatType>;
|
|
559
|
+
/** Number of simulations (default 100) */
|
|
560
|
+
readonly num_simulations: OptionType<IntegerType>;
|
|
561
|
+
}>;
|
|
562
|
+
/**
|
|
563
|
+
* Simulate an unobserved confounder at each given strength - a
|
|
564
|
+
* sensitivity/tipping curve. Strength acts on both treatment
|
|
565
|
+
* (flip probability for binary treatment, linear coefficient otherwise)
|
|
566
|
+
* and outcome (linear coefficient).
|
|
567
|
+
*/
|
|
568
|
+
readonly unobserved_common_cause: StructType<{
|
|
569
|
+
/** Confounder effect strengths to simulate, one new effect per entry */
|
|
570
|
+
readonly effect_strengths: ArrayType<FloatType>;
|
|
571
|
+
}>;
|
|
572
|
+
}>], StructType<{
|
|
573
|
+
/** The original estimated effect being refuted */
|
|
574
|
+
readonly estimated_effect: FloatType;
|
|
575
|
+
/**
|
|
576
|
+
* Effect under the refutation. One entry for placebo/random-common-cause/
|
|
577
|
+
* data-subset; one entry per strength for unobserved_common_cause.
|
|
578
|
+
*/
|
|
579
|
+
readonly new_effects: VectorType<FloatType>;
|
|
580
|
+
/** Refutation p-value where the refuter provides one */
|
|
581
|
+
readonly p_value: OptionType<FloatType>;
|
|
582
|
+
}>>;
|
|
583
|
+
/**
|
|
584
|
+
* Fit an EconML LinearDML estimator for heterogeneous treatment effects.
|
|
585
|
+
*
|
|
586
|
+
* Cross-fits nuisance models for outcome and treatment, then fits a linear
|
|
587
|
+
* CATE model on the residuals.
|
|
588
|
+
*
|
|
589
|
+
* @param Y - Outcome vector
|
|
590
|
+
* @param T - Treatment vector
|
|
591
|
+
* @param X - Effect modifier matrix (CATE varies with these)
|
|
592
|
+
* @param W - Additional confounders adjusted for but not modifying the effect
|
|
593
|
+
* @param config - DML configuration
|
|
594
|
+
* @returns Model blob for use with dmlEffect / dmlAte
|
|
595
|
+
*/
|
|
596
|
+
export declare const causal_dml_train: import("@elaraai/east").PlatformDefinition<[VectorType<FloatType>, VectorType<FloatType>, MatrixType<FloatType>, OptionType<MatrixType<FloatType>>, StructType<{
|
|
597
|
+
/** Nuisance model for the outcome stage (default: random_forest) */
|
|
598
|
+
readonly model_y: OptionType<VariantType<{
|
|
599
|
+
/** Random forest (regressor, or classifier for a discrete treatment) */
|
|
600
|
+
readonly random_forest: StructType<{
|
|
601
|
+
/** Number of trees (default 100) */
|
|
602
|
+
readonly n_estimators: OptionType<IntegerType>;
|
|
603
|
+
/** Minimum samples per leaf (default 5) */
|
|
604
|
+
readonly min_samples_leaf: OptionType<IntegerType>;
|
|
605
|
+
/** Maximum tree depth (default unlimited) */
|
|
606
|
+
readonly max_depth: OptionType<IntegerType>;
|
|
607
|
+
}>;
|
|
608
|
+
/** Gradient boosting (regressor, or classifier for a discrete treatment) */
|
|
609
|
+
readonly gradient_boosting: StructType<{
|
|
610
|
+
/** Number of boosting stages (default 100) */
|
|
611
|
+
readonly n_estimators: OptionType<IntegerType>;
|
|
612
|
+
/** Learning rate (default 0.1) */
|
|
613
|
+
readonly learning_rate: OptionType<FloatType>;
|
|
614
|
+
/** Maximum tree depth (default 3) */
|
|
615
|
+
readonly max_depth: OptionType<IntegerType>;
|
|
616
|
+
}>;
|
|
617
|
+
/** Linear/logistic regression */
|
|
618
|
+
readonly linear: NullType;
|
|
619
|
+
}>>;
|
|
620
|
+
/** Nuisance model for the treatment stage (default: random_forest) */
|
|
621
|
+
readonly model_t: OptionType<VariantType<{
|
|
622
|
+
/** Random forest (regressor, or classifier for a discrete treatment) */
|
|
623
|
+
readonly random_forest: StructType<{
|
|
624
|
+
/** Number of trees (default 100) */
|
|
625
|
+
readonly n_estimators: OptionType<IntegerType>;
|
|
626
|
+
/** Minimum samples per leaf (default 5) */
|
|
627
|
+
readonly min_samples_leaf: OptionType<IntegerType>;
|
|
628
|
+
/** Maximum tree depth (default unlimited) */
|
|
629
|
+
readonly max_depth: OptionType<IntegerType>;
|
|
630
|
+
}>;
|
|
631
|
+
/** Gradient boosting (regressor, or classifier for a discrete treatment) */
|
|
632
|
+
readonly gradient_boosting: StructType<{
|
|
633
|
+
/** Number of boosting stages (default 100) */
|
|
634
|
+
readonly n_estimators: OptionType<IntegerType>;
|
|
635
|
+
/** Learning rate (default 0.1) */
|
|
636
|
+
readonly learning_rate: OptionType<FloatType>;
|
|
637
|
+
/** Maximum tree depth (default 3) */
|
|
638
|
+
readonly max_depth: OptionType<IntegerType>;
|
|
639
|
+
}>;
|
|
640
|
+
/** Linear/logistic regression */
|
|
641
|
+
readonly linear: NullType;
|
|
642
|
+
}>>;
|
|
643
|
+
/** Treat the treatment as discrete/categorical (default false) */
|
|
644
|
+
readonly discrete_treatment: OptionType<BooleanType>;
|
|
645
|
+
/** Cross-fitting folds (default 2) */
|
|
646
|
+
readonly cv_folds: OptionType<IntegerType>;
|
|
647
|
+
/** Confidence level for effect/ATE intervals (default 0.95) */
|
|
648
|
+
readonly confidence_level: OptionType<FloatType>;
|
|
649
|
+
/** Random seed */
|
|
650
|
+
readonly random_state: OptionType<IntegerType>;
|
|
651
|
+
}>], VariantType<{
|
|
652
|
+
/** Fitted EconML LinearDML estimator */
|
|
653
|
+
readonly causal_dml: StructType<{
|
|
654
|
+
/** Serialized estimator (cloudpickle) */
|
|
655
|
+
readonly data: BlobType;
|
|
656
|
+
/** Number of effect-modifier (X) features */
|
|
657
|
+
readonly n_features_x: IntegerType;
|
|
658
|
+
/** Confidence level used for effect/ATE intervals */
|
|
659
|
+
readonly confidence_level: FloatType;
|
|
660
|
+
}>;
|
|
661
|
+
}>>;
|
|
662
|
+
/**
|
|
663
|
+
* Per-row conditional average treatment effects (CATE) from a fitted DML model.
|
|
664
|
+
*
|
|
665
|
+
* @param model - Fitted DML model blob
|
|
666
|
+
* @param X - Effect modifier matrix
|
|
667
|
+
* @returns CATE per row (outcome units per treatment unit)
|
|
668
|
+
*/
|
|
669
|
+
export declare const causal_dml_effect: import("@elaraai/east").PlatformDefinition<[VariantType<{
|
|
670
|
+
/** Fitted EconML LinearDML estimator */
|
|
671
|
+
readonly causal_dml: StructType<{
|
|
672
|
+
/** Serialized estimator (cloudpickle) */
|
|
673
|
+
readonly data: BlobType;
|
|
674
|
+
/** Number of effect-modifier (X) features */
|
|
675
|
+
readonly n_features_x: IntegerType;
|
|
676
|
+
/** Confidence level used for effect/ATE intervals */
|
|
677
|
+
readonly confidence_level: FloatType;
|
|
678
|
+
}>;
|
|
679
|
+
}>, MatrixType<FloatType>], VectorType<FloatType>>;
|
|
680
|
+
/**
|
|
681
|
+
* Average treatment effect with confidence interval from a fitted DML model.
|
|
682
|
+
*
|
|
683
|
+
* @param model - Fitted DML model blob
|
|
684
|
+
* @param X - Effect modifier matrix to average over
|
|
685
|
+
* @returns ATE with interval at the confidence level configured at training
|
|
686
|
+
*/
|
|
687
|
+
export declare const causal_dml_ate: import("@elaraai/east").PlatformDefinition<[VariantType<{
|
|
688
|
+
/** Fitted EconML LinearDML estimator */
|
|
689
|
+
readonly causal_dml: StructType<{
|
|
690
|
+
/** Serialized estimator (cloudpickle) */
|
|
691
|
+
readonly data: BlobType;
|
|
692
|
+
/** Number of effect-modifier (X) features */
|
|
693
|
+
readonly n_features_x: IntegerType;
|
|
694
|
+
/** Confidence level used for effect/ATE intervals */
|
|
695
|
+
readonly confidence_level: FloatType;
|
|
696
|
+
}>;
|
|
697
|
+
}>, MatrixType<FloatType>], StructType<{
|
|
698
|
+
/** Average treatment effect over the given X */
|
|
699
|
+
readonly ate: FloatType;
|
|
700
|
+
/** Lower bound at the model's confidence level */
|
|
701
|
+
readonly lower: FloatType;
|
|
702
|
+
/** Upper bound at the model's confidence level */
|
|
703
|
+
readonly upper: FloatType;
|
|
704
|
+
}>>;
|
|
705
|
+
/**
|
|
706
|
+
* Accumulated local effects dose-response curve of a feature on an outcome.
|
|
707
|
+
*
|
|
708
|
+
* Fits a gradient boosting emulator on all non-outcome columns, then
|
|
709
|
+
* computes the ALE curve of the feature - robust to correlated features,
|
|
710
|
+
* unlike partial dependence.
|
|
711
|
+
*
|
|
712
|
+
* @param data - Data matrix (rows = units, columns named by config.columns)
|
|
713
|
+
* @param config - ALE configuration
|
|
714
|
+
* @returns ALE curve with grid, centered effect, optional CI, and bin sizes
|
|
715
|
+
*/
|
|
716
|
+
export declare const causal_ale: import("@elaraai/east").PlatformDefinition<[MatrixType<FloatType>, StructType<{
|
|
717
|
+
/** Column names for the data matrix (one per column, in order) */
|
|
718
|
+
readonly columns: ArrayType<StringType>;
|
|
719
|
+
/** Outcome column the emulator predicts */
|
|
720
|
+
readonly outcome: StringType;
|
|
721
|
+
/** Continuous feature column to compute the ALE curve for */
|
|
722
|
+
readonly feature: StringType;
|
|
723
|
+
/** Columns holding integer category codes, one-hot encoded internally */
|
|
724
|
+
readonly categorical: OptionType<ArrayType<StringType>>;
|
|
725
|
+
/** Number of grid intervals (default 10) */
|
|
726
|
+
readonly grid_size: OptionType<IntegerType>;
|
|
727
|
+
/** Include confidence intervals (default true) */
|
|
728
|
+
readonly include_ci: OptionType<BooleanType>;
|
|
729
|
+
/** Confidence level for the CI (default 0.95) */
|
|
730
|
+
readonly confidence_level: OptionType<FloatType>;
|
|
731
|
+
/** Emulator (HistGradientBoosting) hyperparameters */
|
|
732
|
+
readonly emulator: OptionType<StructType<{
|
|
733
|
+
/** Number of boosting iterations (default 300) */
|
|
734
|
+
readonly n_estimators: OptionType<IntegerType>;
|
|
735
|
+
/** Learning rate (default 0.05) */
|
|
736
|
+
readonly learning_rate: OptionType<FloatType>;
|
|
737
|
+
/** Maximum tree depth (default unlimited) */
|
|
738
|
+
readonly max_depth: OptionType<IntegerType>;
|
|
739
|
+
/** Minimum samples per leaf (default 20; lower for small datasets) */
|
|
740
|
+
readonly min_samples_leaf: OptionType<IntegerType>;
|
|
741
|
+
}>>;
|
|
742
|
+
/** Random seed for the emulator */
|
|
743
|
+
readonly random_state: OptionType<IntegerType>;
|
|
744
|
+
}>], StructType<{
|
|
745
|
+
/** Feature grid values (interval edges) */
|
|
746
|
+
readonly grid: VectorType<FloatType>;
|
|
747
|
+
/** Centered ALE effect at each grid value (outcome units) */
|
|
748
|
+
readonly effect: VectorType<FloatType>;
|
|
749
|
+
/** Lower CI at each grid value (present when include_ci) */
|
|
750
|
+
readonly lower: OptionType<VectorType<FloatType>>;
|
|
751
|
+
/** Upper CI at each grid value (present when include_ci) */
|
|
752
|
+
readonly upper: OptionType<VectorType<FloatType>>;
|
|
753
|
+
/** Number of samples in each grid interval */
|
|
754
|
+
readonly size: VectorType<IntegerType>;
|
|
755
|
+
}>>;
|
|
756
|
+
/**
|
|
757
|
+
* Type definitions for causal inference functions.
|
|
758
|
+
*/
|
|
759
|
+
export declare const CausalTypes: {
|
|
760
|
+
readonly CausalWeightingSchemeType: VariantType<{
|
|
761
|
+
/** Raw inverse propensity weights */
|
|
762
|
+
readonly ips_weight: NullType;
|
|
763
|
+
/** Stabilized inverse propensity weights (recommended; lower variance) */
|
|
764
|
+
readonly ips_stabilized_weight: NullType;
|
|
765
|
+
/** Normalized inverse propensity weights */
|
|
766
|
+
readonly ips_normalized_weight: NullType;
|
|
767
|
+
}>;
|
|
768
|
+
readonly CausalEstimatorType: VariantType<{
|
|
769
|
+
/** Linear regression of outcome on treatment + common causes */
|
|
770
|
+
readonly linear_regression: NullType;
|
|
771
|
+
/** Inverse propensity score weighting (binary treatment only) */
|
|
772
|
+
readonly propensity_score_weighting: StructType<{
|
|
773
|
+
/** Weighting scheme (default: ips_stabilized_weight) */
|
|
774
|
+
readonly weighting_scheme: OptionType<VariantType<{
|
|
775
|
+
/** Raw inverse propensity weights */
|
|
776
|
+
readonly ips_weight: NullType;
|
|
777
|
+
/** Stabilized inverse propensity weights (recommended; lower variance) */
|
|
778
|
+
readonly ips_stabilized_weight: NullType;
|
|
779
|
+
/** Normalized inverse propensity weights */
|
|
780
|
+
readonly ips_normalized_weight: NullType;
|
|
781
|
+
}>>;
|
|
782
|
+
}>;
|
|
783
|
+
}>;
|
|
784
|
+
readonly CausalTargetUnitsType: VariantType<{
|
|
785
|
+
/** Average treatment effect over all units */
|
|
786
|
+
readonly ate: NullType;
|
|
787
|
+
/** Average treatment effect on the treated */
|
|
788
|
+
readonly att: NullType;
|
|
789
|
+
/** Average treatment effect on the controls */
|
|
790
|
+
readonly atc: NullType;
|
|
791
|
+
}>;
|
|
792
|
+
readonly PropensityTrimType: VariantType<{
|
|
793
|
+
/** Keep units inside the common-support overlap of treated and control propensities */
|
|
794
|
+
readonly overlap: NullType;
|
|
795
|
+
/** Keep units with propensity inside explicit bounds */
|
|
796
|
+
readonly bounds: StructType<{
|
|
797
|
+
/** Minimum propensity score to keep */
|
|
798
|
+
readonly lower: FloatType;
|
|
799
|
+
/** Maximum propensity score to keep */
|
|
800
|
+
readonly upper: FloatType;
|
|
801
|
+
}>;
|
|
802
|
+
}>;
|
|
803
|
+
readonly CausalBootstrapConfigType: StructType<{
|
|
804
|
+
/** Number of bootstrap replicates */
|
|
805
|
+
readonly reps: IntegerType;
|
|
806
|
+
/** Column whose values identify clusters to resample (default: resample rows) */
|
|
807
|
+
readonly cluster_column: OptionType<StringType>;
|
|
808
|
+
/** Confidence level for the percentile interval (default 0.95) */
|
|
809
|
+
readonly confidence_level: OptionType<FloatType>;
|
|
810
|
+
}>;
|
|
811
|
+
readonly CausalEffectConfigType: StructType<{
|
|
812
|
+
/** Column names for the data matrix (one per column, in order) */
|
|
813
|
+
readonly columns: ArrayType<StringType>;
|
|
814
|
+
/** Treatment column (must be 0/1 for propensity score weighting) */
|
|
815
|
+
readonly treatment: StringType;
|
|
816
|
+
/** Outcome column */
|
|
817
|
+
readonly outcome: StringType;
|
|
818
|
+
/** Confounder columns to adjust for (the backdoor set) */
|
|
819
|
+
readonly common_causes: ArrayType<StringType>;
|
|
820
|
+
/** Columns holding integer category codes, one-hot encoded internally */
|
|
821
|
+
readonly categorical: OptionType<ArrayType<StringType>>;
|
|
822
|
+
/** Effect estimator (default: linear_regression) */
|
|
823
|
+
readonly method: OptionType<VariantType<{
|
|
824
|
+
/** Linear regression of outcome on treatment + common causes */
|
|
825
|
+
readonly linear_regression: NullType;
|
|
826
|
+
/** Inverse propensity score weighting (binary treatment only) */
|
|
827
|
+
readonly propensity_score_weighting: StructType<{
|
|
828
|
+
/** Weighting scheme (default: ips_stabilized_weight) */
|
|
829
|
+
readonly weighting_scheme: OptionType<VariantType<{
|
|
830
|
+
/** Raw inverse propensity weights */
|
|
831
|
+
readonly ips_weight: NullType;
|
|
832
|
+
/** Stabilized inverse propensity weights (recommended; lower variance) */
|
|
833
|
+
readonly ips_stabilized_weight: NullType;
|
|
834
|
+
/** Normalized inverse propensity weights */
|
|
835
|
+
readonly ips_normalized_weight: NullType;
|
|
836
|
+
}>>;
|
|
837
|
+
}>;
|
|
838
|
+
}>>;
|
|
839
|
+
/** Target population (default: ate) */
|
|
840
|
+
readonly target_units: OptionType<VariantType<{
|
|
841
|
+
/** Average treatment effect over all units */
|
|
842
|
+
readonly ate: NullType;
|
|
843
|
+
/** Average treatment effect on the treated */
|
|
844
|
+
readonly att: NullType;
|
|
845
|
+
/** Average treatment effect on the controls */
|
|
846
|
+
readonly atc: NullType;
|
|
847
|
+
}>>;
|
|
848
|
+
/** Propensity trimming applied before estimation (psw only) */
|
|
849
|
+
readonly trim: OptionType<VariantType<{
|
|
850
|
+
/** Keep units inside the common-support overlap of treated and control propensities */
|
|
851
|
+
readonly overlap: NullType;
|
|
852
|
+
/** Keep units with propensity inside explicit bounds */
|
|
853
|
+
readonly bounds: StructType<{
|
|
854
|
+
/** Minimum propensity score to keep */
|
|
855
|
+
readonly lower: FloatType;
|
|
856
|
+
/** Maximum propensity score to keep */
|
|
857
|
+
readonly upper: FloatType;
|
|
858
|
+
}>;
|
|
859
|
+
}>>;
|
|
860
|
+
/** Bootstrap confidence interval (omit to skip CI computation) */
|
|
861
|
+
readonly bootstrap: OptionType<StructType<{
|
|
862
|
+
/** Number of bootstrap replicates */
|
|
863
|
+
readonly reps: IntegerType;
|
|
864
|
+
/** Column whose values identify clusters to resample (default: resample rows) */
|
|
865
|
+
readonly cluster_column: OptionType<StringType>;
|
|
866
|
+
/** Confidence level for the percentile interval (default 0.95) */
|
|
867
|
+
readonly confidence_level: OptionType<FloatType>;
|
|
868
|
+
}>>;
|
|
869
|
+
/** Random seed for propensity fitting and bootstrap resampling */
|
|
870
|
+
readonly random_state: OptionType<IntegerType>;
|
|
871
|
+
}>;
|
|
872
|
+
readonly CausalRefuterType: VariantType<{
|
|
873
|
+
/** Replace treatment with a permuted placebo - effect should vanish */
|
|
874
|
+
readonly placebo_treatment: StructType<{
|
|
875
|
+
/** Number of simulations (default 100) */
|
|
876
|
+
readonly num_simulations: OptionType<IntegerType>;
|
|
877
|
+
}>;
|
|
878
|
+
/** Add an independent random common cause - effect should be unchanged */
|
|
879
|
+
readonly random_common_cause: StructType<{
|
|
880
|
+
/** Number of simulations (default 100) */
|
|
881
|
+
readonly num_simulations: OptionType<IntegerType>;
|
|
882
|
+
}>;
|
|
883
|
+
/** Re-estimate on random data subsets - effect should be stable */
|
|
884
|
+
readonly data_subset: StructType<{
|
|
885
|
+
/** Fraction of rows kept per simulation (default 0.8) */
|
|
886
|
+
readonly subset_fraction: OptionType<FloatType>;
|
|
887
|
+
/** Number of simulations (default 100) */
|
|
888
|
+
readonly num_simulations: OptionType<IntegerType>;
|
|
889
|
+
}>;
|
|
890
|
+
/**
|
|
891
|
+
* Simulate an unobserved confounder at each given strength - a
|
|
892
|
+
* sensitivity/tipping curve. Strength acts on both treatment
|
|
893
|
+
* (flip probability for binary treatment, linear coefficient otherwise)
|
|
894
|
+
* and outcome (linear coefficient).
|
|
895
|
+
*/
|
|
896
|
+
readonly unobserved_common_cause: StructType<{
|
|
897
|
+
/** Confounder effect strengths to simulate, one new effect per entry */
|
|
898
|
+
readonly effect_strengths: ArrayType<FloatType>;
|
|
899
|
+
}>;
|
|
900
|
+
}>;
|
|
901
|
+
readonly CausalNuisanceModelType: VariantType<{
|
|
902
|
+
/** Random forest (regressor, or classifier for a discrete treatment) */
|
|
903
|
+
readonly random_forest: StructType<{
|
|
904
|
+
/** Number of trees (default 100) */
|
|
905
|
+
readonly n_estimators: OptionType<IntegerType>;
|
|
906
|
+
/** Minimum samples per leaf (default 5) */
|
|
907
|
+
readonly min_samples_leaf: OptionType<IntegerType>;
|
|
908
|
+
/** Maximum tree depth (default unlimited) */
|
|
909
|
+
readonly max_depth: OptionType<IntegerType>;
|
|
910
|
+
}>;
|
|
911
|
+
/** Gradient boosting (regressor, or classifier for a discrete treatment) */
|
|
912
|
+
readonly gradient_boosting: StructType<{
|
|
913
|
+
/** Number of boosting stages (default 100) */
|
|
914
|
+
readonly n_estimators: OptionType<IntegerType>;
|
|
915
|
+
/** Learning rate (default 0.1) */
|
|
916
|
+
readonly learning_rate: OptionType<FloatType>;
|
|
917
|
+
/** Maximum tree depth (default 3) */
|
|
918
|
+
readonly max_depth: OptionType<IntegerType>;
|
|
919
|
+
}>;
|
|
920
|
+
/** Linear/logistic regression */
|
|
921
|
+
readonly linear: NullType;
|
|
922
|
+
}>;
|
|
923
|
+
readonly CausalDMLConfigType: StructType<{
|
|
924
|
+
/** Nuisance model for the outcome stage (default: random_forest) */
|
|
925
|
+
readonly model_y: OptionType<VariantType<{
|
|
926
|
+
/** Random forest (regressor, or classifier for a discrete treatment) */
|
|
927
|
+
readonly random_forest: StructType<{
|
|
928
|
+
/** Number of trees (default 100) */
|
|
929
|
+
readonly n_estimators: OptionType<IntegerType>;
|
|
930
|
+
/** Minimum samples per leaf (default 5) */
|
|
931
|
+
readonly min_samples_leaf: OptionType<IntegerType>;
|
|
932
|
+
/** Maximum tree depth (default unlimited) */
|
|
933
|
+
readonly max_depth: OptionType<IntegerType>;
|
|
934
|
+
}>;
|
|
935
|
+
/** Gradient boosting (regressor, or classifier for a discrete treatment) */
|
|
936
|
+
readonly gradient_boosting: StructType<{
|
|
937
|
+
/** Number of boosting stages (default 100) */
|
|
938
|
+
readonly n_estimators: OptionType<IntegerType>;
|
|
939
|
+
/** Learning rate (default 0.1) */
|
|
940
|
+
readonly learning_rate: OptionType<FloatType>;
|
|
941
|
+
/** Maximum tree depth (default 3) */
|
|
942
|
+
readonly max_depth: OptionType<IntegerType>;
|
|
943
|
+
}>;
|
|
944
|
+
/** Linear/logistic regression */
|
|
945
|
+
readonly linear: NullType;
|
|
946
|
+
}>>;
|
|
947
|
+
/** Nuisance model for the treatment stage (default: random_forest) */
|
|
948
|
+
readonly model_t: OptionType<VariantType<{
|
|
949
|
+
/** Random forest (regressor, or classifier for a discrete treatment) */
|
|
950
|
+
readonly random_forest: StructType<{
|
|
951
|
+
/** Number of trees (default 100) */
|
|
952
|
+
readonly n_estimators: OptionType<IntegerType>;
|
|
953
|
+
/** Minimum samples per leaf (default 5) */
|
|
954
|
+
readonly min_samples_leaf: OptionType<IntegerType>;
|
|
955
|
+
/** Maximum tree depth (default unlimited) */
|
|
956
|
+
readonly max_depth: OptionType<IntegerType>;
|
|
957
|
+
}>;
|
|
958
|
+
/** Gradient boosting (regressor, or classifier for a discrete treatment) */
|
|
959
|
+
readonly gradient_boosting: StructType<{
|
|
960
|
+
/** Number of boosting stages (default 100) */
|
|
961
|
+
readonly n_estimators: OptionType<IntegerType>;
|
|
962
|
+
/** Learning rate (default 0.1) */
|
|
963
|
+
readonly learning_rate: OptionType<FloatType>;
|
|
964
|
+
/** Maximum tree depth (default 3) */
|
|
965
|
+
readonly max_depth: OptionType<IntegerType>;
|
|
966
|
+
}>;
|
|
967
|
+
/** Linear/logistic regression */
|
|
968
|
+
readonly linear: NullType;
|
|
969
|
+
}>>;
|
|
970
|
+
/** Treat the treatment as discrete/categorical (default false) */
|
|
971
|
+
readonly discrete_treatment: OptionType<BooleanType>;
|
|
972
|
+
/** Cross-fitting folds (default 2) */
|
|
973
|
+
readonly cv_folds: OptionType<IntegerType>;
|
|
974
|
+
/** Confidence level for effect/ATE intervals (default 0.95) */
|
|
975
|
+
readonly confidence_level: OptionType<FloatType>;
|
|
976
|
+
/** Random seed */
|
|
977
|
+
readonly random_state: OptionType<IntegerType>;
|
|
978
|
+
}>;
|
|
979
|
+
readonly CausalALEConfigType: StructType<{
|
|
980
|
+
/** Column names for the data matrix (one per column, in order) */
|
|
981
|
+
readonly columns: ArrayType<StringType>;
|
|
982
|
+
/** Outcome column the emulator predicts */
|
|
983
|
+
readonly outcome: StringType;
|
|
984
|
+
/** Continuous feature column to compute the ALE curve for */
|
|
985
|
+
readonly feature: StringType;
|
|
986
|
+
/** Columns holding integer category codes, one-hot encoded internally */
|
|
987
|
+
readonly categorical: OptionType<ArrayType<StringType>>;
|
|
988
|
+
/** Number of grid intervals (default 10) */
|
|
989
|
+
readonly grid_size: OptionType<IntegerType>;
|
|
990
|
+
/** Include confidence intervals (default true) */
|
|
991
|
+
readonly include_ci: OptionType<BooleanType>;
|
|
992
|
+
/** Confidence level for the CI (default 0.95) */
|
|
993
|
+
readonly confidence_level: OptionType<FloatType>;
|
|
994
|
+
/** Emulator (HistGradientBoosting) hyperparameters */
|
|
995
|
+
readonly emulator: OptionType<StructType<{
|
|
996
|
+
/** Number of boosting iterations (default 300) */
|
|
997
|
+
readonly n_estimators: OptionType<IntegerType>;
|
|
998
|
+
/** Learning rate (default 0.05) */
|
|
999
|
+
readonly learning_rate: OptionType<FloatType>;
|
|
1000
|
+
/** Maximum tree depth (default unlimited) */
|
|
1001
|
+
readonly max_depth: OptionType<IntegerType>;
|
|
1002
|
+
/** Minimum samples per leaf (default 20; lower for small datasets) */
|
|
1003
|
+
readonly min_samples_leaf: OptionType<IntegerType>;
|
|
1004
|
+
}>>;
|
|
1005
|
+
/** Random seed for the emulator */
|
|
1006
|
+
readonly random_state: OptionType<IntegerType>;
|
|
1007
|
+
}>;
|
|
1008
|
+
readonly CausalDMLModelBlobType: VariantType<{
|
|
1009
|
+
/** Fitted EconML LinearDML estimator */
|
|
1010
|
+
readonly causal_dml: StructType<{
|
|
1011
|
+
/** Serialized estimator (cloudpickle) */
|
|
1012
|
+
readonly data: BlobType;
|
|
1013
|
+
/** Number of effect-modifier (X) features */
|
|
1014
|
+
readonly n_features_x: IntegerType;
|
|
1015
|
+
/** Confidence level used for effect/ATE intervals */
|
|
1016
|
+
readonly confidence_level: FloatType;
|
|
1017
|
+
}>;
|
|
1018
|
+
}>;
|
|
1019
|
+
readonly CausalEffectResultType: StructType<{
|
|
1020
|
+
/** Point estimate of the effect (outcome units per treatment unit) */
|
|
1021
|
+
readonly effect: FloatType;
|
|
1022
|
+
/** Bootstrap percentile confidence interval (present when bootstrap configured) */
|
|
1023
|
+
readonly ci: OptionType<StructType<{
|
|
1024
|
+
/** Lower bound */
|
|
1025
|
+
readonly lower: FloatType;
|
|
1026
|
+
/** Upper bound */
|
|
1027
|
+
readonly upper: FloatType;
|
|
1028
|
+
}>>;
|
|
1029
|
+
/** Rows used for estimation (after trimming) */
|
|
1030
|
+
readonly n_samples: IntegerType;
|
|
1031
|
+
/** Treated rows used */
|
|
1032
|
+
readonly n_treated: IntegerType;
|
|
1033
|
+
/** Control rows used */
|
|
1034
|
+
readonly n_control: IntegerType;
|
|
1035
|
+
}>;
|
|
1036
|
+
readonly CausalRefuteResultType: StructType<{
|
|
1037
|
+
/** The original estimated effect being refuted */
|
|
1038
|
+
readonly estimated_effect: FloatType;
|
|
1039
|
+
/**
|
|
1040
|
+
* Effect under the refutation. One entry for placebo/random-common-cause/
|
|
1041
|
+
* data-subset; one entry per strength for unobserved_common_cause.
|
|
1042
|
+
*/
|
|
1043
|
+
readonly new_effects: VectorType<FloatType>;
|
|
1044
|
+
/** Refutation p-value where the refuter provides one */
|
|
1045
|
+
readonly p_value: OptionType<FloatType>;
|
|
1046
|
+
}>;
|
|
1047
|
+
readonly CausalATEResultType: StructType<{
|
|
1048
|
+
/** Average treatment effect over the given X */
|
|
1049
|
+
readonly ate: FloatType;
|
|
1050
|
+
/** Lower bound at the model's confidence level */
|
|
1051
|
+
readonly lower: FloatType;
|
|
1052
|
+
/** Upper bound at the model's confidence level */
|
|
1053
|
+
readonly upper: FloatType;
|
|
1054
|
+
}>;
|
|
1055
|
+
readonly ALEResultType: StructType<{
|
|
1056
|
+
/** Feature grid values (interval edges) */
|
|
1057
|
+
readonly grid: VectorType<FloatType>;
|
|
1058
|
+
/** Centered ALE effect at each grid value (outcome units) */
|
|
1059
|
+
readonly effect: VectorType<FloatType>;
|
|
1060
|
+
/** Lower CI at each grid value (present when include_ci) */
|
|
1061
|
+
readonly lower: OptionType<VectorType<FloatType>>;
|
|
1062
|
+
/** Upper CI at each grid value (present when include_ci) */
|
|
1063
|
+
readonly upper: OptionType<VectorType<FloatType>>;
|
|
1064
|
+
/** Number of samples in each grid interval */
|
|
1065
|
+
readonly size: VectorType<IntegerType>;
|
|
1066
|
+
}>;
|
|
1067
|
+
};
|
|
1068
|
+
/**
|
|
1069
|
+
* Causal inference.
|
|
1070
|
+
*
|
|
1071
|
+
* Backdoor-adjusted effect estimation and refutation (DoWhy),
|
|
1072
|
+
* heterogeneous treatment effects via double machine learning
|
|
1073
|
+
* (EconML LinearDML), and accumulated local effects dose-response
|
|
1074
|
+
* curves (PyALE).
|
|
1075
|
+
*
|
|
1076
|
+
* @example
|
|
1077
|
+
* ```ts
|
|
1078
|
+
* import { East, FloatType, variant } from "@elaraai/east";
|
|
1079
|
+
* import { Causal, MatrixType } from "@elaraai/east-py-datascience";
|
|
1080
|
+
*
|
|
1081
|
+
* const estimate = East.function(
|
|
1082
|
+
* [MatrixType(FloatType)],
|
|
1083
|
+
* Causal.Types.CausalEffectResultType,
|
|
1084
|
+
* ($, data) => {
|
|
1085
|
+
* const config = $.let({
|
|
1086
|
+
* columns: ["treated", "outcome", "confounder"],
|
|
1087
|
+
* treatment: "treated",
|
|
1088
|
+
* outcome: "outcome",
|
|
1089
|
+
* common_causes: ["confounder"],
|
|
1090
|
+
* categorical: variant('none', null),
|
|
1091
|
+
* method: variant('some', variant('linear_regression', null)),
|
|
1092
|
+
* target_units: variant('some', variant('ate', null)),
|
|
1093
|
+
* trim: variant('none', null),
|
|
1094
|
+
* bootstrap: variant('none', null),
|
|
1095
|
+
* random_state: variant('some', 42n),
|
|
1096
|
+
* }, Causal.Types.CausalEffectConfigType);
|
|
1097
|
+
* return $.return(Causal.effect(data, config));
|
|
1098
|
+
* }
|
|
1099
|
+
* );
|
|
1100
|
+
* ```
|
|
1101
|
+
*/
|
|
1102
|
+
export declare const Causal: {
|
|
1103
|
+
/**
|
|
1104
|
+
* Estimate a backdoor-adjusted causal effect of treatment on outcome.
|
|
1105
|
+
*
|
|
1106
|
+
* Linear regression or inverse propensity score weighting (with
|
|
1107
|
+
* optional propensity trimming), plus optional cluster bootstrap CI.
|
|
1108
|
+
*
|
|
1109
|
+
* @example
|
|
1110
|
+
* ```ts
|
|
1111
|
+
* import { East, FloatType, variant } from "@elaraai/east";
|
|
1112
|
+
* import { Causal, CausalEffectConfigType, MatrixType } from "@elaraai/east-py-datascience";
|
|
1113
|
+
*
|
|
1114
|
+
* const attEstimate = East.function(
|
|
1115
|
+
* [MatrixType(FloatType)],
|
|
1116
|
+
* Causal.Types.CausalEffectResultType,
|
|
1117
|
+
* ($, data) => {
|
|
1118
|
+
* const config = $.let({
|
|
1119
|
+
* columns: ["treated", "outcome", "z1", "z2", "batch"],
|
|
1120
|
+
* treatment: "treated",
|
|
1121
|
+
* outcome: "outcome",
|
|
1122
|
+
* common_causes: ["z1", "z2"],
|
|
1123
|
+
* categorical: variant('none', null),
|
|
1124
|
+
* method: variant('some', variant('propensity_score_weighting', {
|
|
1125
|
+
* weighting_scheme: variant('some', variant('ips_stabilized_weight', null)),
|
|
1126
|
+
* })),
|
|
1127
|
+
* target_units: variant('some', variant('att', null)),
|
|
1128
|
+
* trim: variant('some', variant('overlap', null)),
|
|
1129
|
+
* bootstrap: variant('some', {
|
|
1130
|
+
* reps: 200n,
|
|
1131
|
+
* cluster_column: variant('some', "batch"),
|
|
1132
|
+
* confidence_level: variant('some', 0.95),
|
|
1133
|
+
* }),
|
|
1134
|
+
* random_state: variant('some', 42n),
|
|
1135
|
+
* }, CausalEffectConfigType);
|
|
1136
|
+
* return $.return(Causal.effect(data, config));
|
|
1137
|
+
* }
|
|
1138
|
+
* );
|
|
1139
|
+
* ```
|
|
1140
|
+
*/
|
|
1141
|
+
readonly effect: import("@elaraai/east").PlatformDefinition<[MatrixType<FloatType>, StructType<{
|
|
1142
|
+
/** Column names for the data matrix (one per column, in order) */
|
|
1143
|
+
readonly columns: ArrayType<StringType>;
|
|
1144
|
+
/** Treatment column (must be 0/1 for propensity score weighting) */
|
|
1145
|
+
readonly treatment: StringType;
|
|
1146
|
+
/** Outcome column */
|
|
1147
|
+
readonly outcome: StringType;
|
|
1148
|
+
/** Confounder columns to adjust for (the backdoor set) */
|
|
1149
|
+
readonly common_causes: ArrayType<StringType>;
|
|
1150
|
+
/** Columns holding integer category codes, one-hot encoded internally */
|
|
1151
|
+
readonly categorical: OptionType<ArrayType<StringType>>;
|
|
1152
|
+
/** Effect estimator (default: linear_regression) */
|
|
1153
|
+
readonly method: OptionType<VariantType<{
|
|
1154
|
+
/** Linear regression of outcome on treatment + common causes */
|
|
1155
|
+
readonly linear_regression: NullType;
|
|
1156
|
+
/** Inverse propensity score weighting (binary treatment only) */
|
|
1157
|
+
readonly propensity_score_weighting: StructType<{
|
|
1158
|
+
/** Weighting scheme (default: ips_stabilized_weight) */
|
|
1159
|
+
readonly weighting_scheme: OptionType<VariantType<{
|
|
1160
|
+
/** Raw inverse propensity weights */
|
|
1161
|
+
readonly ips_weight: NullType;
|
|
1162
|
+
/** Stabilized inverse propensity weights (recommended; lower variance) */
|
|
1163
|
+
readonly ips_stabilized_weight: NullType;
|
|
1164
|
+
/** Normalized inverse propensity weights */
|
|
1165
|
+
readonly ips_normalized_weight: NullType;
|
|
1166
|
+
}>>;
|
|
1167
|
+
}>;
|
|
1168
|
+
}>>;
|
|
1169
|
+
/** Target population (default: ate) */
|
|
1170
|
+
readonly target_units: OptionType<VariantType<{
|
|
1171
|
+
/** Average treatment effect over all units */
|
|
1172
|
+
readonly ate: NullType;
|
|
1173
|
+
/** Average treatment effect on the treated */
|
|
1174
|
+
readonly att: NullType;
|
|
1175
|
+
/** Average treatment effect on the controls */
|
|
1176
|
+
readonly atc: NullType;
|
|
1177
|
+
}>>;
|
|
1178
|
+
/** Propensity trimming applied before estimation (psw only) */
|
|
1179
|
+
readonly trim: OptionType<VariantType<{
|
|
1180
|
+
/** Keep units inside the common-support overlap of treated and control propensities */
|
|
1181
|
+
readonly overlap: NullType;
|
|
1182
|
+
/** Keep units with propensity inside explicit bounds */
|
|
1183
|
+
readonly bounds: StructType<{
|
|
1184
|
+
/** Minimum propensity score to keep */
|
|
1185
|
+
readonly lower: FloatType;
|
|
1186
|
+
/** Maximum propensity score to keep */
|
|
1187
|
+
readonly upper: FloatType;
|
|
1188
|
+
}>;
|
|
1189
|
+
}>>;
|
|
1190
|
+
/** Bootstrap confidence interval (omit to skip CI computation) */
|
|
1191
|
+
readonly bootstrap: OptionType<StructType<{
|
|
1192
|
+
/** Number of bootstrap replicates */
|
|
1193
|
+
readonly reps: IntegerType;
|
|
1194
|
+
/** Column whose values identify clusters to resample (default: resample rows) */
|
|
1195
|
+
readonly cluster_column: OptionType<StringType>;
|
|
1196
|
+
/** Confidence level for the percentile interval (default 0.95) */
|
|
1197
|
+
readonly confidence_level: OptionType<FloatType>;
|
|
1198
|
+
}>>;
|
|
1199
|
+
/** Random seed for propensity fitting and bootstrap resampling */
|
|
1200
|
+
readonly random_state: OptionType<IntegerType>;
|
|
1201
|
+
}>], StructType<{
|
|
1202
|
+
/** Point estimate of the effect (outcome units per treatment unit) */
|
|
1203
|
+
readonly effect: FloatType;
|
|
1204
|
+
/** Bootstrap percentile confidence interval (present when bootstrap configured) */
|
|
1205
|
+
readonly ci: OptionType<StructType<{
|
|
1206
|
+
/** Lower bound */
|
|
1207
|
+
readonly lower: FloatType;
|
|
1208
|
+
/** Upper bound */
|
|
1209
|
+
readonly upper: FloatType;
|
|
1210
|
+
}>>;
|
|
1211
|
+
/** Rows used for estimation (after trimming) */
|
|
1212
|
+
readonly n_samples: IntegerType;
|
|
1213
|
+
/** Treated rows used */
|
|
1214
|
+
readonly n_treated: IntegerType;
|
|
1215
|
+
/** Control rows used */
|
|
1216
|
+
readonly n_control: IntegerType;
|
|
1217
|
+
}>>;
|
|
1218
|
+
/**
|
|
1219
|
+
* Refute an estimated causal effect with placebo, random common cause,
|
|
1220
|
+
* data subset, or unobserved-confounder sensitivity tests.
|
|
1221
|
+
*
|
|
1222
|
+
* @example
|
|
1223
|
+
* ```ts
|
|
1224
|
+
* import { East, FloatType, variant } from "@elaraai/east";
|
|
1225
|
+
* import { Causal, MatrixType } from "@elaraai/east-py-datascience";
|
|
1226
|
+
*
|
|
1227
|
+
* const placebo = East.function(
|
|
1228
|
+
* [MatrixType(FloatType), Causal.Types.CausalEffectConfigType],
|
|
1229
|
+
* Causal.Types.CausalRefuteResultType,
|
|
1230
|
+
* ($, data, config) => {
|
|
1231
|
+
* const refuter = $.let(variant('placebo_treatment', {
|
|
1232
|
+
* num_simulations: variant('some', 50n),
|
|
1233
|
+
* }), Causal.Types.CausalRefuterType);
|
|
1234
|
+
* // new_effects should be near zero if the estimate is causal
|
|
1235
|
+
* return $.return(Causal.refute(data, config, refuter));
|
|
1236
|
+
* }
|
|
1237
|
+
* );
|
|
1238
|
+
* ```
|
|
1239
|
+
*/
|
|
1240
|
+
readonly refute: import("@elaraai/east").PlatformDefinition<[MatrixType<FloatType>, StructType<{
|
|
1241
|
+
/** Column names for the data matrix (one per column, in order) */
|
|
1242
|
+
readonly columns: ArrayType<StringType>;
|
|
1243
|
+
/** Treatment column (must be 0/1 for propensity score weighting) */
|
|
1244
|
+
readonly treatment: StringType;
|
|
1245
|
+
/** Outcome column */
|
|
1246
|
+
readonly outcome: StringType;
|
|
1247
|
+
/** Confounder columns to adjust for (the backdoor set) */
|
|
1248
|
+
readonly common_causes: ArrayType<StringType>;
|
|
1249
|
+
/** Columns holding integer category codes, one-hot encoded internally */
|
|
1250
|
+
readonly categorical: OptionType<ArrayType<StringType>>;
|
|
1251
|
+
/** Effect estimator (default: linear_regression) */
|
|
1252
|
+
readonly method: OptionType<VariantType<{
|
|
1253
|
+
/** Linear regression of outcome on treatment + common causes */
|
|
1254
|
+
readonly linear_regression: NullType;
|
|
1255
|
+
/** Inverse propensity score weighting (binary treatment only) */
|
|
1256
|
+
readonly propensity_score_weighting: StructType<{
|
|
1257
|
+
/** Weighting scheme (default: ips_stabilized_weight) */
|
|
1258
|
+
readonly weighting_scheme: OptionType<VariantType<{
|
|
1259
|
+
/** Raw inverse propensity weights */
|
|
1260
|
+
readonly ips_weight: NullType;
|
|
1261
|
+
/** Stabilized inverse propensity weights (recommended; lower variance) */
|
|
1262
|
+
readonly ips_stabilized_weight: NullType;
|
|
1263
|
+
/** Normalized inverse propensity weights */
|
|
1264
|
+
readonly ips_normalized_weight: NullType;
|
|
1265
|
+
}>>;
|
|
1266
|
+
}>;
|
|
1267
|
+
}>>;
|
|
1268
|
+
/** Target population (default: ate) */
|
|
1269
|
+
readonly target_units: OptionType<VariantType<{
|
|
1270
|
+
/** Average treatment effect over all units */
|
|
1271
|
+
readonly ate: NullType;
|
|
1272
|
+
/** Average treatment effect on the treated */
|
|
1273
|
+
readonly att: NullType;
|
|
1274
|
+
/** Average treatment effect on the controls */
|
|
1275
|
+
readonly atc: NullType;
|
|
1276
|
+
}>>;
|
|
1277
|
+
/** Propensity trimming applied before estimation (psw only) */
|
|
1278
|
+
readonly trim: OptionType<VariantType<{
|
|
1279
|
+
/** Keep units inside the common-support overlap of treated and control propensities */
|
|
1280
|
+
readonly overlap: NullType;
|
|
1281
|
+
/** Keep units with propensity inside explicit bounds */
|
|
1282
|
+
readonly bounds: StructType<{
|
|
1283
|
+
/** Minimum propensity score to keep */
|
|
1284
|
+
readonly lower: FloatType;
|
|
1285
|
+
/** Maximum propensity score to keep */
|
|
1286
|
+
readonly upper: FloatType;
|
|
1287
|
+
}>;
|
|
1288
|
+
}>>;
|
|
1289
|
+
/** Bootstrap confidence interval (omit to skip CI computation) */
|
|
1290
|
+
readonly bootstrap: OptionType<StructType<{
|
|
1291
|
+
/** Number of bootstrap replicates */
|
|
1292
|
+
readonly reps: IntegerType;
|
|
1293
|
+
/** Column whose values identify clusters to resample (default: resample rows) */
|
|
1294
|
+
readonly cluster_column: OptionType<StringType>;
|
|
1295
|
+
/** Confidence level for the percentile interval (default 0.95) */
|
|
1296
|
+
readonly confidence_level: OptionType<FloatType>;
|
|
1297
|
+
}>>;
|
|
1298
|
+
/** Random seed for propensity fitting and bootstrap resampling */
|
|
1299
|
+
readonly random_state: OptionType<IntegerType>;
|
|
1300
|
+
}>, VariantType<{
|
|
1301
|
+
/** Replace treatment with a permuted placebo - effect should vanish */
|
|
1302
|
+
readonly placebo_treatment: StructType<{
|
|
1303
|
+
/** Number of simulations (default 100) */
|
|
1304
|
+
readonly num_simulations: OptionType<IntegerType>;
|
|
1305
|
+
}>;
|
|
1306
|
+
/** Add an independent random common cause - effect should be unchanged */
|
|
1307
|
+
readonly random_common_cause: StructType<{
|
|
1308
|
+
/** Number of simulations (default 100) */
|
|
1309
|
+
readonly num_simulations: OptionType<IntegerType>;
|
|
1310
|
+
}>;
|
|
1311
|
+
/** Re-estimate on random data subsets - effect should be stable */
|
|
1312
|
+
readonly data_subset: StructType<{
|
|
1313
|
+
/** Fraction of rows kept per simulation (default 0.8) */
|
|
1314
|
+
readonly subset_fraction: OptionType<FloatType>;
|
|
1315
|
+
/** Number of simulations (default 100) */
|
|
1316
|
+
readonly num_simulations: OptionType<IntegerType>;
|
|
1317
|
+
}>;
|
|
1318
|
+
/**
|
|
1319
|
+
* Simulate an unobserved confounder at each given strength - a
|
|
1320
|
+
* sensitivity/tipping curve. Strength acts on both treatment
|
|
1321
|
+
* (flip probability for binary treatment, linear coefficient otherwise)
|
|
1322
|
+
* and outcome (linear coefficient).
|
|
1323
|
+
*/
|
|
1324
|
+
readonly unobserved_common_cause: StructType<{
|
|
1325
|
+
/** Confounder effect strengths to simulate, one new effect per entry */
|
|
1326
|
+
readonly effect_strengths: ArrayType<FloatType>;
|
|
1327
|
+
}>;
|
|
1328
|
+
}>], StructType<{
|
|
1329
|
+
/** The original estimated effect being refuted */
|
|
1330
|
+
readonly estimated_effect: FloatType;
|
|
1331
|
+
/**
|
|
1332
|
+
* Effect under the refutation. One entry for placebo/random-common-cause/
|
|
1333
|
+
* data-subset; one entry per strength for unobserved_common_cause.
|
|
1334
|
+
*/
|
|
1335
|
+
readonly new_effects: VectorType<FloatType>;
|
|
1336
|
+
/** Refutation p-value where the refuter provides one */
|
|
1337
|
+
readonly p_value: OptionType<FloatType>;
|
|
1338
|
+
}>>;
|
|
1339
|
+
/**
|
|
1340
|
+
* Fit an EconML LinearDML estimator for heterogeneous treatment effects.
|
|
1341
|
+
*
|
|
1342
|
+
* @example
|
|
1343
|
+
* ```ts
|
|
1344
|
+
* import { East, FloatType, variant } from "@elaraai/east";
|
|
1345
|
+
* import { Causal, CausalDMLConfigType, MatrixType, VectorType } from "@elaraai/east-py-datascience";
|
|
1346
|
+
*
|
|
1347
|
+
* const train = East.function(
|
|
1348
|
+
* [VectorType(FloatType), VectorType(FloatType), MatrixType(FloatType), MatrixType(FloatType)],
|
|
1349
|
+
* Causal.Types.CausalDMLModelBlobType,
|
|
1350
|
+
* ($, Y, T, X, W) => {
|
|
1351
|
+
* const config = $.let({
|
|
1352
|
+
* model_y: variant('some', variant('random_forest', {
|
|
1353
|
+
* n_estimators: variant('some', 100n),
|
|
1354
|
+
* min_samples_leaf: variant('some', 5n),
|
|
1355
|
+
* max_depth: variant('none', null),
|
|
1356
|
+
* })),
|
|
1357
|
+
* model_t: variant('none', null),
|
|
1358
|
+
* discrete_treatment: variant('none', null),
|
|
1359
|
+
* cv_folds: variant('some', 2n),
|
|
1360
|
+
* confidence_level: variant('some', 0.95),
|
|
1361
|
+
* random_state: variant('some', 42n),
|
|
1362
|
+
* }, CausalDMLConfigType);
|
|
1363
|
+
* return $.return(Causal.dmlTrain(Y, T, X, variant('some', W), config));
|
|
1364
|
+
* }
|
|
1365
|
+
* );
|
|
1366
|
+
* ```
|
|
1367
|
+
*/
|
|
1368
|
+
readonly dmlTrain: import("@elaraai/east").PlatformDefinition<[VectorType<FloatType>, VectorType<FloatType>, MatrixType<FloatType>, OptionType<MatrixType<FloatType>>, StructType<{
|
|
1369
|
+
/** Nuisance model for the outcome stage (default: random_forest) */
|
|
1370
|
+
readonly model_y: OptionType<VariantType<{
|
|
1371
|
+
/** Random forest (regressor, or classifier for a discrete treatment) */
|
|
1372
|
+
readonly random_forest: StructType<{
|
|
1373
|
+
/** Number of trees (default 100) */
|
|
1374
|
+
readonly n_estimators: OptionType<IntegerType>;
|
|
1375
|
+
/** Minimum samples per leaf (default 5) */
|
|
1376
|
+
readonly min_samples_leaf: OptionType<IntegerType>;
|
|
1377
|
+
/** Maximum tree depth (default unlimited) */
|
|
1378
|
+
readonly max_depth: OptionType<IntegerType>;
|
|
1379
|
+
}>;
|
|
1380
|
+
/** Gradient boosting (regressor, or classifier for a discrete treatment) */
|
|
1381
|
+
readonly gradient_boosting: StructType<{
|
|
1382
|
+
/** Number of boosting stages (default 100) */
|
|
1383
|
+
readonly n_estimators: OptionType<IntegerType>;
|
|
1384
|
+
/** Learning rate (default 0.1) */
|
|
1385
|
+
readonly learning_rate: OptionType<FloatType>;
|
|
1386
|
+
/** Maximum tree depth (default 3) */
|
|
1387
|
+
readonly max_depth: OptionType<IntegerType>;
|
|
1388
|
+
}>;
|
|
1389
|
+
/** Linear/logistic regression */
|
|
1390
|
+
readonly linear: NullType;
|
|
1391
|
+
}>>;
|
|
1392
|
+
/** Nuisance model for the treatment stage (default: random_forest) */
|
|
1393
|
+
readonly model_t: OptionType<VariantType<{
|
|
1394
|
+
/** Random forest (regressor, or classifier for a discrete treatment) */
|
|
1395
|
+
readonly random_forest: StructType<{
|
|
1396
|
+
/** Number of trees (default 100) */
|
|
1397
|
+
readonly n_estimators: OptionType<IntegerType>;
|
|
1398
|
+
/** Minimum samples per leaf (default 5) */
|
|
1399
|
+
readonly min_samples_leaf: OptionType<IntegerType>;
|
|
1400
|
+
/** Maximum tree depth (default unlimited) */
|
|
1401
|
+
readonly max_depth: OptionType<IntegerType>;
|
|
1402
|
+
}>;
|
|
1403
|
+
/** Gradient boosting (regressor, or classifier for a discrete treatment) */
|
|
1404
|
+
readonly gradient_boosting: StructType<{
|
|
1405
|
+
/** Number of boosting stages (default 100) */
|
|
1406
|
+
readonly n_estimators: OptionType<IntegerType>;
|
|
1407
|
+
/** Learning rate (default 0.1) */
|
|
1408
|
+
readonly learning_rate: OptionType<FloatType>;
|
|
1409
|
+
/** Maximum tree depth (default 3) */
|
|
1410
|
+
readonly max_depth: OptionType<IntegerType>;
|
|
1411
|
+
}>;
|
|
1412
|
+
/** Linear/logistic regression */
|
|
1413
|
+
readonly linear: NullType;
|
|
1414
|
+
}>>;
|
|
1415
|
+
/** Treat the treatment as discrete/categorical (default false) */
|
|
1416
|
+
readonly discrete_treatment: OptionType<BooleanType>;
|
|
1417
|
+
/** Cross-fitting folds (default 2) */
|
|
1418
|
+
readonly cv_folds: OptionType<IntegerType>;
|
|
1419
|
+
/** Confidence level for effect/ATE intervals (default 0.95) */
|
|
1420
|
+
readonly confidence_level: OptionType<FloatType>;
|
|
1421
|
+
/** Random seed */
|
|
1422
|
+
readonly random_state: OptionType<IntegerType>;
|
|
1423
|
+
}>], VariantType<{
|
|
1424
|
+
/** Fitted EconML LinearDML estimator */
|
|
1425
|
+
readonly causal_dml: StructType<{
|
|
1426
|
+
/** Serialized estimator (cloudpickle) */
|
|
1427
|
+
readonly data: BlobType;
|
|
1428
|
+
/** Number of effect-modifier (X) features */
|
|
1429
|
+
readonly n_features_x: IntegerType;
|
|
1430
|
+
/** Confidence level used for effect/ATE intervals */
|
|
1431
|
+
readonly confidence_level: FloatType;
|
|
1432
|
+
}>;
|
|
1433
|
+
}>>;
|
|
1434
|
+
/**
|
|
1435
|
+
* Per-row conditional average treatment effects from a fitted DML model.
|
|
1436
|
+
*
|
|
1437
|
+
* @example
|
|
1438
|
+
* ```ts
|
|
1439
|
+
* import { East, FloatType } from "@elaraai/east";
|
|
1440
|
+
* import { Causal, MatrixType, VectorType } from "@elaraai/east-py-datascience";
|
|
1441
|
+
*
|
|
1442
|
+
* const cate = East.function(
|
|
1443
|
+
* [Causal.Types.CausalDMLModelBlobType, MatrixType(FloatType)],
|
|
1444
|
+
* VectorType(FloatType),
|
|
1445
|
+
* ($, model, X) => $.return(Causal.dmlEffect(model, X))
|
|
1446
|
+
* );
|
|
1447
|
+
* ```
|
|
1448
|
+
*/
|
|
1449
|
+
readonly dmlEffect: import("@elaraai/east").PlatformDefinition<[VariantType<{
|
|
1450
|
+
/** Fitted EconML LinearDML estimator */
|
|
1451
|
+
readonly causal_dml: StructType<{
|
|
1452
|
+
/** Serialized estimator (cloudpickle) */
|
|
1453
|
+
readonly data: BlobType;
|
|
1454
|
+
/** Number of effect-modifier (X) features */
|
|
1455
|
+
readonly n_features_x: IntegerType;
|
|
1456
|
+
/** Confidence level used for effect/ATE intervals */
|
|
1457
|
+
readonly confidence_level: FloatType;
|
|
1458
|
+
}>;
|
|
1459
|
+
}>, MatrixType<FloatType>], VectorType<FloatType>>;
|
|
1460
|
+
/**
|
|
1461
|
+
* Average treatment effect with confidence interval from a fitted DML model.
|
|
1462
|
+
*
|
|
1463
|
+
* @example
|
|
1464
|
+
* ```ts
|
|
1465
|
+
* import { East, FloatType } from "@elaraai/east";
|
|
1466
|
+
* import { Causal, MatrixType } from "@elaraai/east-py-datascience";
|
|
1467
|
+
*
|
|
1468
|
+
* const ate = East.function(
|
|
1469
|
+
* [Causal.Types.CausalDMLModelBlobType, MatrixType(FloatType)],
|
|
1470
|
+
* Causal.Types.CausalATEResultType,
|
|
1471
|
+
* ($, model, X) => $.return(Causal.dmlAte(model, X))
|
|
1472
|
+
* );
|
|
1473
|
+
* ```
|
|
1474
|
+
*/
|
|
1475
|
+
readonly dmlAte: import("@elaraai/east").PlatformDefinition<[VariantType<{
|
|
1476
|
+
/** Fitted EconML LinearDML estimator */
|
|
1477
|
+
readonly causal_dml: StructType<{
|
|
1478
|
+
/** Serialized estimator (cloudpickle) */
|
|
1479
|
+
readonly data: BlobType;
|
|
1480
|
+
/** Number of effect-modifier (X) features */
|
|
1481
|
+
readonly n_features_x: IntegerType;
|
|
1482
|
+
/** Confidence level used for effect/ATE intervals */
|
|
1483
|
+
readonly confidence_level: FloatType;
|
|
1484
|
+
}>;
|
|
1485
|
+
}>, MatrixType<FloatType>], StructType<{
|
|
1486
|
+
/** Average treatment effect over the given X */
|
|
1487
|
+
readonly ate: FloatType;
|
|
1488
|
+
/** Lower bound at the model's confidence level */
|
|
1489
|
+
readonly lower: FloatType;
|
|
1490
|
+
/** Upper bound at the model's confidence level */
|
|
1491
|
+
readonly upper: FloatType;
|
|
1492
|
+
}>>;
|
|
1493
|
+
/**
|
|
1494
|
+
* Accumulated local effects dose-response curve of a feature on an outcome.
|
|
1495
|
+
*
|
|
1496
|
+
* @example
|
|
1497
|
+
* ```ts
|
|
1498
|
+
* import { East, FloatType, variant } from "@elaraai/east";
|
|
1499
|
+
* import { Causal, CausalALEConfigType, MatrixType } from "@elaraai/east-py-datascience";
|
|
1500
|
+
*
|
|
1501
|
+
* const doseResponse = East.function(
|
|
1502
|
+
* [MatrixType(FloatType)],
|
|
1503
|
+
* Causal.Types.ALEResultType,
|
|
1504
|
+
* ($, data) => {
|
|
1505
|
+
* const config = $.let({
|
|
1506
|
+
* columns: ["dose", "z", "response"],
|
|
1507
|
+
* outcome: "response",
|
|
1508
|
+
* feature: "dose",
|
|
1509
|
+
* categorical: variant('none', null),
|
|
1510
|
+
* grid_size: variant('some', 10n),
|
|
1511
|
+
* include_ci: variant('some', true),
|
|
1512
|
+
* confidence_level: variant('some', 0.95),
|
|
1513
|
+
* emulator: variant('none', null),
|
|
1514
|
+
* random_state: variant('some', 42n),
|
|
1515
|
+
* }, CausalALEConfigType);
|
|
1516
|
+
* return $.return(Causal.ale(data, config));
|
|
1517
|
+
* }
|
|
1518
|
+
* );
|
|
1519
|
+
* ```
|
|
1520
|
+
*/
|
|
1521
|
+
readonly ale: import("@elaraai/east").PlatformDefinition<[MatrixType<FloatType>, StructType<{
|
|
1522
|
+
/** Column names for the data matrix (one per column, in order) */
|
|
1523
|
+
readonly columns: ArrayType<StringType>;
|
|
1524
|
+
/** Outcome column the emulator predicts */
|
|
1525
|
+
readonly outcome: StringType;
|
|
1526
|
+
/** Continuous feature column to compute the ALE curve for */
|
|
1527
|
+
readonly feature: StringType;
|
|
1528
|
+
/** Columns holding integer category codes, one-hot encoded internally */
|
|
1529
|
+
readonly categorical: OptionType<ArrayType<StringType>>;
|
|
1530
|
+
/** Number of grid intervals (default 10) */
|
|
1531
|
+
readonly grid_size: OptionType<IntegerType>;
|
|
1532
|
+
/** Include confidence intervals (default true) */
|
|
1533
|
+
readonly include_ci: OptionType<BooleanType>;
|
|
1534
|
+
/** Confidence level for the CI (default 0.95) */
|
|
1535
|
+
readonly confidence_level: OptionType<FloatType>;
|
|
1536
|
+
/** Emulator (HistGradientBoosting) hyperparameters */
|
|
1537
|
+
readonly emulator: OptionType<StructType<{
|
|
1538
|
+
/** Number of boosting iterations (default 300) */
|
|
1539
|
+
readonly n_estimators: OptionType<IntegerType>;
|
|
1540
|
+
/** Learning rate (default 0.05) */
|
|
1541
|
+
readonly learning_rate: OptionType<FloatType>;
|
|
1542
|
+
/** Maximum tree depth (default unlimited) */
|
|
1543
|
+
readonly max_depth: OptionType<IntegerType>;
|
|
1544
|
+
/** Minimum samples per leaf (default 20; lower for small datasets) */
|
|
1545
|
+
readonly min_samples_leaf: OptionType<IntegerType>;
|
|
1546
|
+
}>>;
|
|
1547
|
+
/** Random seed for the emulator */
|
|
1548
|
+
readonly random_state: OptionType<IntegerType>;
|
|
1549
|
+
}>], StructType<{
|
|
1550
|
+
/** Feature grid values (interval edges) */
|
|
1551
|
+
readonly grid: VectorType<FloatType>;
|
|
1552
|
+
/** Centered ALE effect at each grid value (outcome units) */
|
|
1553
|
+
readonly effect: VectorType<FloatType>;
|
|
1554
|
+
/** Lower CI at each grid value (present when include_ci) */
|
|
1555
|
+
readonly lower: OptionType<VectorType<FloatType>>;
|
|
1556
|
+
/** Upper CI at each grid value (present when include_ci) */
|
|
1557
|
+
readonly upper: OptionType<VectorType<FloatType>>;
|
|
1558
|
+
/** Number of samples in each grid interval */
|
|
1559
|
+
readonly size: VectorType<IntegerType>;
|
|
1560
|
+
}>>;
|
|
1561
|
+
/** Type definitions */
|
|
1562
|
+
readonly Types: {
|
|
1563
|
+
readonly CausalWeightingSchemeType: VariantType<{
|
|
1564
|
+
/** Raw inverse propensity weights */
|
|
1565
|
+
readonly ips_weight: NullType;
|
|
1566
|
+
/** Stabilized inverse propensity weights (recommended; lower variance) */
|
|
1567
|
+
readonly ips_stabilized_weight: NullType;
|
|
1568
|
+
/** Normalized inverse propensity weights */
|
|
1569
|
+
readonly ips_normalized_weight: NullType;
|
|
1570
|
+
}>;
|
|
1571
|
+
readonly CausalEstimatorType: VariantType<{
|
|
1572
|
+
/** Linear regression of outcome on treatment + common causes */
|
|
1573
|
+
readonly linear_regression: NullType;
|
|
1574
|
+
/** Inverse propensity score weighting (binary treatment only) */
|
|
1575
|
+
readonly propensity_score_weighting: StructType<{
|
|
1576
|
+
/** Weighting scheme (default: ips_stabilized_weight) */
|
|
1577
|
+
readonly weighting_scheme: OptionType<VariantType<{
|
|
1578
|
+
/** Raw inverse propensity weights */
|
|
1579
|
+
readonly ips_weight: NullType;
|
|
1580
|
+
/** Stabilized inverse propensity weights (recommended; lower variance) */
|
|
1581
|
+
readonly ips_stabilized_weight: NullType;
|
|
1582
|
+
/** Normalized inverse propensity weights */
|
|
1583
|
+
readonly ips_normalized_weight: NullType;
|
|
1584
|
+
}>>;
|
|
1585
|
+
}>;
|
|
1586
|
+
}>;
|
|
1587
|
+
readonly CausalTargetUnitsType: VariantType<{
|
|
1588
|
+
/** Average treatment effect over all units */
|
|
1589
|
+
readonly ate: NullType;
|
|
1590
|
+
/** Average treatment effect on the treated */
|
|
1591
|
+
readonly att: NullType;
|
|
1592
|
+
/** Average treatment effect on the controls */
|
|
1593
|
+
readonly atc: NullType;
|
|
1594
|
+
}>;
|
|
1595
|
+
readonly PropensityTrimType: VariantType<{
|
|
1596
|
+
/** Keep units inside the common-support overlap of treated and control propensities */
|
|
1597
|
+
readonly overlap: NullType;
|
|
1598
|
+
/** Keep units with propensity inside explicit bounds */
|
|
1599
|
+
readonly bounds: StructType<{
|
|
1600
|
+
/** Minimum propensity score to keep */
|
|
1601
|
+
readonly lower: FloatType;
|
|
1602
|
+
/** Maximum propensity score to keep */
|
|
1603
|
+
readonly upper: FloatType;
|
|
1604
|
+
}>;
|
|
1605
|
+
}>;
|
|
1606
|
+
readonly CausalBootstrapConfigType: StructType<{
|
|
1607
|
+
/** Number of bootstrap replicates */
|
|
1608
|
+
readonly reps: IntegerType;
|
|
1609
|
+
/** Column whose values identify clusters to resample (default: resample rows) */
|
|
1610
|
+
readonly cluster_column: OptionType<StringType>;
|
|
1611
|
+
/** Confidence level for the percentile interval (default 0.95) */
|
|
1612
|
+
readonly confidence_level: OptionType<FloatType>;
|
|
1613
|
+
}>;
|
|
1614
|
+
readonly CausalEffectConfigType: StructType<{
|
|
1615
|
+
/** Column names for the data matrix (one per column, in order) */
|
|
1616
|
+
readonly columns: ArrayType<StringType>;
|
|
1617
|
+
/** Treatment column (must be 0/1 for propensity score weighting) */
|
|
1618
|
+
readonly treatment: StringType;
|
|
1619
|
+
/** Outcome column */
|
|
1620
|
+
readonly outcome: StringType;
|
|
1621
|
+
/** Confounder columns to adjust for (the backdoor set) */
|
|
1622
|
+
readonly common_causes: ArrayType<StringType>;
|
|
1623
|
+
/** Columns holding integer category codes, one-hot encoded internally */
|
|
1624
|
+
readonly categorical: OptionType<ArrayType<StringType>>;
|
|
1625
|
+
/** Effect estimator (default: linear_regression) */
|
|
1626
|
+
readonly method: OptionType<VariantType<{
|
|
1627
|
+
/** Linear regression of outcome on treatment + common causes */
|
|
1628
|
+
readonly linear_regression: NullType;
|
|
1629
|
+
/** Inverse propensity score weighting (binary treatment only) */
|
|
1630
|
+
readonly propensity_score_weighting: StructType<{
|
|
1631
|
+
/** Weighting scheme (default: ips_stabilized_weight) */
|
|
1632
|
+
readonly weighting_scheme: OptionType<VariantType<{
|
|
1633
|
+
/** Raw inverse propensity weights */
|
|
1634
|
+
readonly ips_weight: NullType;
|
|
1635
|
+
/** Stabilized inverse propensity weights (recommended; lower variance) */
|
|
1636
|
+
readonly ips_stabilized_weight: NullType;
|
|
1637
|
+
/** Normalized inverse propensity weights */
|
|
1638
|
+
readonly ips_normalized_weight: NullType;
|
|
1639
|
+
}>>;
|
|
1640
|
+
}>;
|
|
1641
|
+
}>>;
|
|
1642
|
+
/** Target population (default: ate) */
|
|
1643
|
+
readonly target_units: OptionType<VariantType<{
|
|
1644
|
+
/** Average treatment effect over all units */
|
|
1645
|
+
readonly ate: NullType;
|
|
1646
|
+
/** Average treatment effect on the treated */
|
|
1647
|
+
readonly att: NullType;
|
|
1648
|
+
/** Average treatment effect on the controls */
|
|
1649
|
+
readonly atc: NullType;
|
|
1650
|
+
}>>;
|
|
1651
|
+
/** Propensity trimming applied before estimation (psw only) */
|
|
1652
|
+
readonly trim: OptionType<VariantType<{
|
|
1653
|
+
/** Keep units inside the common-support overlap of treated and control propensities */
|
|
1654
|
+
readonly overlap: NullType;
|
|
1655
|
+
/** Keep units with propensity inside explicit bounds */
|
|
1656
|
+
readonly bounds: StructType<{
|
|
1657
|
+
/** Minimum propensity score to keep */
|
|
1658
|
+
readonly lower: FloatType;
|
|
1659
|
+
/** Maximum propensity score to keep */
|
|
1660
|
+
readonly upper: FloatType;
|
|
1661
|
+
}>;
|
|
1662
|
+
}>>;
|
|
1663
|
+
/** Bootstrap confidence interval (omit to skip CI computation) */
|
|
1664
|
+
readonly bootstrap: OptionType<StructType<{
|
|
1665
|
+
/** Number of bootstrap replicates */
|
|
1666
|
+
readonly reps: IntegerType;
|
|
1667
|
+
/** Column whose values identify clusters to resample (default: resample rows) */
|
|
1668
|
+
readonly cluster_column: OptionType<StringType>;
|
|
1669
|
+
/** Confidence level for the percentile interval (default 0.95) */
|
|
1670
|
+
readonly confidence_level: OptionType<FloatType>;
|
|
1671
|
+
}>>;
|
|
1672
|
+
/** Random seed for propensity fitting and bootstrap resampling */
|
|
1673
|
+
readonly random_state: OptionType<IntegerType>;
|
|
1674
|
+
}>;
|
|
1675
|
+
readonly CausalRefuterType: VariantType<{
|
|
1676
|
+
/** Replace treatment with a permuted placebo - effect should vanish */
|
|
1677
|
+
readonly placebo_treatment: StructType<{
|
|
1678
|
+
/** Number of simulations (default 100) */
|
|
1679
|
+
readonly num_simulations: OptionType<IntegerType>;
|
|
1680
|
+
}>;
|
|
1681
|
+
/** Add an independent random common cause - effect should be unchanged */
|
|
1682
|
+
readonly random_common_cause: StructType<{
|
|
1683
|
+
/** Number of simulations (default 100) */
|
|
1684
|
+
readonly num_simulations: OptionType<IntegerType>;
|
|
1685
|
+
}>;
|
|
1686
|
+
/** Re-estimate on random data subsets - effect should be stable */
|
|
1687
|
+
readonly data_subset: StructType<{
|
|
1688
|
+
/** Fraction of rows kept per simulation (default 0.8) */
|
|
1689
|
+
readonly subset_fraction: OptionType<FloatType>;
|
|
1690
|
+
/** Number of simulations (default 100) */
|
|
1691
|
+
readonly num_simulations: OptionType<IntegerType>;
|
|
1692
|
+
}>;
|
|
1693
|
+
/**
|
|
1694
|
+
* Simulate an unobserved confounder at each given strength - a
|
|
1695
|
+
* sensitivity/tipping curve. Strength acts on both treatment
|
|
1696
|
+
* (flip probability for binary treatment, linear coefficient otherwise)
|
|
1697
|
+
* and outcome (linear coefficient).
|
|
1698
|
+
*/
|
|
1699
|
+
readonly unobserved_common_cause: StructType<{
|
|
1700
|
+
/** Confounder effect strengths to simulate, one new effect per entry */
|
|
1701
|
+
readonly effect_strengths: ArrayType<FloatType>;
|
|
1702
|
+
}>;
|
|
1703
|
+
}>;
|
|
1704
|
+
readonly CausalNuisanceModelType: VariantType<{
|
|
1705
|
+
/** Random forest (regressor, or classifier for a discrete treatment) */
|
|
1706
|
+
readonly random_forest: StructType<{
|
|
1707
|
+
/** Number of trees (default 100) */
|
|
1708
|
+
readonly n_estimators: OptionType<IntegerType>;
|
|
1709
|
+
/** Minimum samples per leaf (default 5) */
|
|
1710
|
+
readonly min_samples_leaf: OptionType<IntegerType>;
|
|
1711
|
+
/** Maximum tree depth (default unlimited) */
|
|
1712
|
+
readonly max_depth: OptionType<IntegerType>;
|
|
1713
|
+
}>;
|
|
1714
|
+
/** Gradient boosting (regressor, or classifier for a discrete treatment) */
|
|
1715
|
+
readonly gradient_boosting: StructType<{
|
|
1716
|
+
/** Number of boosting stages (default 100) */
|
|
1717
|
+
readonly n_estimators: OptionType<IntegerType>;
|
|
1718
|
+
/** Learning rate (default 0.1) */
|
|
1719
|
+
readonly learning_rate: OptionType<FloatType>;
|
|
1720
|
+
/** Maximum tree depth (default 3) */
|
|
1721
|
+
readonly max_depth: OptionType<IntegerType>;
|
|
1722
|
+
}>;
|
|
1723
|
+
/** Linear/logistic regression */
|
|
1724
|
+
readonly linear: NullType;
|
|
1725
|
+
}>;
|
|
1726
|
+
readonly CausalDMLConfigType: StructType<{
|
|
1727
|
+
/** Nuisance model for the outcome stage (default: random_forest) */
|
|
1728
|
+
readonly model_y: OptionType<VariantType<{
|
|
1729
|
+
/** Random forest (regressor, or classifier for a discrete treatment) */
|
|
1730
|
+
readonly random_forest: StructType<{
|
|
1731
|
+
/** Number of trees (default 100) */
|
|
1732
|
+
readonly n_estimators: OptionType<IntegerType>;
|
|
1733
|
+
/** Minimum samples per leaf (default 5) */
|
|
1734
|
+
readonly min_samples_leaf: OptionType<IntegerType>;
|
|
1735
|
+
/** Maximum tree depth (default unlimited) */
|
|
1736
|
+
readonly max_depth: OptionType<IntegerType>;
|
|
1737
|
+
}>;
|
|
1738
|
+
/** Gradient boosting (regressor, or classifier for a discrete treatment) */
|
|
1739
|
+
readonly gradient_boosting: StructType<{
|
|
1740
|
+
/** Number of boosting stages (default 100) */
|
|
1741
|
+
readonly n_estimators: OptionType<IntegerType>;
|
|
1742
|
+
/** Learning rate (default 0.1) */
|
|
1743
|
+
readonly learning_rate: OptionType<FloatType>;
|
|
1744
|
+
/** Maximum tree depth (default 3) */
|
|
1745
|
+
readonly max_depth: OptionType<IntegerType>;
|
|
1746
|
+
}>;
|
|
1747
|
+
/** Linear/logistic regression */
|
|
1748
|
+
readonly linear: NullType;
|
|
1749
|
+
}>>;
|
|
1750
|
+
/** Nuisance model for the treatment stage (default: random_forest) */
|
|
1751
|
+
readonly model_t: OptionType<VariantType<{
|
|
1752
|
+
/** Random forest (regressor, or classifier for a discrete treatment) */
|
|
1753
|
+
readonly random_forest: StructType<{
|
|
1754
|
+
/** Number of trees (default 100) */
|
|
1755
|
+
readonly n_estimators: OptionType<IntegerType>;
|
|
1756
|
+
/** Minimum samples per leaf (default 5) */
|
|
1757
|
+
readonly min_samples_leaf: OptionType<IntegerType>;
|
|
1758
|
+
/** Maximum tree depth (default unlimited) */
|
|
1759
|
+
readonly max_depth: OptionType<IntegerType>;
|
|
1760
|
+
}>;
|
|
1761
|
+
/** Gradient boosting (regressor, or classifier for a discrete treatment) */
|
|
1762
|
+
readonly gradient_boosting: StructType<{
|
|
1763
|
+
/** Number of boosting stages (default 100) */
|
|
1764
|
+
readonly n_estimators: OptionType<IntegerType>;
|
|
1765
|
+
/** Learning rate (default 0.1) */
|
|
1766
|
+
readonly learning_rate: OptionType<FloatType>;
|
|
1767
|
+
/** Maximum tree depth (default 3) */
|
|
1768
|
+
readonly max_depth: OptionType<IntegerType>;
|
|
1769
|
+
}>;
|
|
1770
|
+
/** Linear/logistic regression */
|
|
1771
|
+
readonly linear: NullType;
|
|
1772
|
+
}>>;
|
|
1773
|
+
/** Treat the treatment as discrete/categorical (default false) */
|
|
1774
|
+
readonly discrete_treatment: OptionType<BooleanType>;
|
|
1775
|
+
/** Cross-fitting folds (default 2) */
|
|
1776
|
+
readonly cv_folds: OptionType<IntegerType>;
|
|
1777
|
+
/** Confidence level for effect/ATE intervals (default 0.95) */
|
|
1778
|
+
readonly confidence_level: OptionType<FloatType>;
|
|
1779
|
+
/** Random seed */
|
|
1780
|
+
readonly random_state: OptionType<IntegerType>;
|
|
1781
|
+
}>;
|
|
1782
|
+
readonly CausalALEConfigType: StructType<{
|
|
1783
|
+
/** Column names for the data matrix (one per column, in order) */
|
|
1784
|
+
readonly columns: ArrayType<StringType>;
|
|
1785
|
+
/** Outcome column the emulator predicts */
|
|
1786
|
+
readonly outcome: StringType;
|
|
1787
|
+
/** Continuous feature column to compute the ALE curve for */
|
|
1788
|
+
readonly feature: StringType;
|
|
1789
|
+
/** Columns holding integer category codes, one-hot encoded internally */
|
|
1790
|
+
readonly categorical: OptionType<ArrayType<StringType>>;
|
|
1791
|
+
/** Number of grid intervals (default 10) */
|
|
1792
|
+
readonly grid_size: OptionType<IntegerType>;
|
|
1793
|
+
/** Include confidence intervals (default true) */
|
|
1794
|
+
readonly include_ci: OptionType<BooleanType>;
|
|
1795
|
+
/** Confidence level for the CI (default 0.95) */
|
|
1796
|
+
readonly confidence_level: OptionType<FloatType>;
|
|
1797
|
+
/** Emulator (HistGradientBoosting) hyperparameters */
|
|
1798
|
+
readonly emulator: OptionType<StructType<{
|
|
1799
|
+
/** Number of boosting iterations (default 300) */
|
|
1800
|
+
readonly n_estimators: OptionType<IntegerType>;
|
|
1801
|
+
/** Learning rate (default 0.05) */
|
|
1802
|
+
readonly learning_rate: OptionType<FloatType>;
|
|
1803
|
+
/** Maximum tree depth (default unlimited) */
|
|
1804
|
+
readonly max_depth: OptionType<IntegerType>;
|
|
1805
|
+
/** Minimum samples per leaf (default 20; lower for small datasets) */
|
|
1806
|
+
readonly min_samples_leaf: OptionType<IntegerType>;
|
|
1807
|
+
}>>;
|
|
1808
|
+
/** Random seed for the emulator */
|
|
1809
|
+
readonly random_state: OptionType<IntegerType>;
|
|
1810
|
+
}>;
|
|
1811
|
+
readonly CausalDMLModelBlobType: VariantType<{
|
|
1812
|
+
/** Fitted EconML LinearDML estimator */
|
|
1813
|
+
readonly causal_dml: StructType<{
|
|
1814
|
+
/** Serialized estimator (cloudpickle) */
|
|
1815
|
+
readonly data: BlobType;
|
|
1816
|
+
/** Number of effect-modifier (X) features */
|
|
1817
|
+
readonly n_features_x: IntegerType;
|
|
1818
|
+
/** Confidence level used for effect/ATE intervals */
|
|
1819
|
+
readonly confidence_level: FloatType;
|
|
1820
|
+
}>;
|
|
1821
|
+
}>;
|
|
1822
|
+
readonly CausalEffectResultType: StructType<{
|
|
1823
|
+
/** Point estimate of the effect (outcome units per treatment unit) */
|
|
1824
|
+
readonly effect: FloatType;
|
|
1825
|
+
/** Bootstrap percentile confidence interval (present when bootstrap configured) */
|
|
1826
|
+
readonly ci: OptionType<StructType<{
|
|
1827
|
+
/** Lower bound */
|
|
1828
|
+
readonly lower: FloatType;
|
|
1829
|
+
/** Upper bound */
|
|
1830
|
+
readonly upper: FloatType;
|
|
1831
|
+
}>>;
|
|
1832
|
+
/** Rows used for estimation (after trimming) */
|
|
1833
|
+
readonly n_samples: IntegerType;
|
|
1834
|
+
/** Treated rows used */
|
|
1835
|
+
readonly n_treated: IntegerType;
|
|
1836
|
+
/** Control rows used */
|
|
1837
|
+
readonly n_control: IntegerType;
|
|
1838
|
+
}>;
|
|
1839
|
+
readonly CausalRefuteResultType: StructType<{
|
|
1840
|
+
/** The original estimated effect being refuted */
|
|
1841
|
+
readonly estimated_effect: FloatType;
|
|
1842
|
+
/**
|
|
1843
|
+
* Effect under the refutation. One entry for placebo/random-common-cause/
|
|
1844
|
+
* data-subset; one entry per strength for unobserved_common_cause.
|
|
1845
|
+
*/
|
|
1846
|
+
readonly new_effects: VectorType<FloatType>;
|
|
1847
|
+
/** Refutation p-value where the refuter provides one */
|
|
1848
|
+
readonly p_value: OptionType<FloatType>;
|
|
1849
|
+
}>;
|
|
1850
|
+
readonly CausalATEResultType: StructType<{
|
|
1851
|
+
/** Average treatment effect over the given X */
|
|
1852
|
+
readonly ate: FloatType;
|
|
1853
|
+
/** Lower bound at the model's confidence level */
|
|
1854
|
+
readonly lower: FloatType;
|
|
1855
|
+
/** Upper bound at the model's confidence level */
|
|
1856
|
+
readonly upper: FloatType;
|
|
1857
|
+
}>;
|
|
1858
|
+
readonly ALEResultType: StructType<{
|
|
1859
|
+
/** Feature grid values (interval edges) */
|
|
1860
|
+
readonly grid: VectorType<FloatType>;
|
|
1861
|
+
/** Centered ALE effect at each grid value (outcome units) */
|
|
1862
|
+
readonly effect: VectorType<FloatType>;
|
|
1863
|
+
/** Lower CI at each grid value (present when include_ci) */
|
|
1864
|
+
readonly lower: OptionType<VectorType<FloatType>>;
|
|
1865
|
+
/** Upper CI at each grid value (present when include_ci) */
|
|
1866
|
+
readonly upper: OptionType<VectorType<FloatType>>;
|
|
1867
|
+
/** Number of samples in each grid interval */
|
|
1868
|
+
readonly size: VectorType<IntegerType>;
|
|
1869
|
+
}>;
|
|
1870
|
+
};
|
|
1871
|
+
};
|
|
1872
|
+
//# sourceMappingURL=causal.d.ts.map
|