metacausal.adapters.EconMLAdapter¶
- class metacausal.adapters.EconMLAdapter(model, name=None, *, alpha=0.05, inference=None)[source]¶
Bases:
objectWrap an initialized-but-unfitted EconML estimator.
Supports any EconML estimator with
.fit(Y, T, X=X)and.ate(X=X)or.effect(X=X)methods. The estimator template is deep-copied duringfit()so that the original remains reusable for bootstrap resampling.- Parameters:
model – An initialized (unfitted) EconML estimator instance.
name (str | None) – Display name. Defaults to the class name.
alpha (float) – Significance level for analytical confidence intervals. Passed through to
ate_interval()/effect_interval().inference (Any) – Optional EconML fit-time inference backend, forwarded to
model.fit(..., inference=inference).
Examples
>>> from econml.dml import LinearDML >>> from metacausal.adapters import EconMLAdapter >>> from metacausal.datasets import load_lalonde >>> from sklearn.ensemble import ( ... HistGradientBoostingRegressor as HGBR, ... HistGradientBoostingClassifier as HGBC, ... ) >>> X, T, Y = load_lalonde() >>> dml = EconMLAdapter( ... LinearDML( ... model_y=HGBR(max_iter=20), model_t=HGBC(max_iter=20), ... discrete_treatment=True, cv=2, ... ), ... ) >>> dml.fit(X, T, Y, random_state=42) >>> result = dml.ate() >>> result ComponentAteEstimate(ate=..., ci=[..., ...])
Methods
__init__For binary outcomes, the wrapped EconML estimator must have
discrete_outcome=Trueand a classifier in the slot that models the conditional outcome (model_yforCausalForestDML,model_regressionforDRLearner).Attributes
Details