metacausal.adapters.DoubleMLAdapter¶
- class metacausal.adapters.DoubleMLAdapter(model_class, name=None, alpha=0.05, **kwargs)[source]¶
Bases:
objectWrap a DoubleML estimator class for use in CausalEnsemble.
DoubleML bundles data and model at construction time, so this adapter accepts the class and nuisance model configuration (not an initialized object). A fresh DoubleML object is constructed and fitted on each call to
fit(), which is essential for bootstrap resampling.- Parameters:
model_class (type) – A DoubleML class, e.g.
DoubleMLIRMorDoubleMLPLR.name (str | None) – Display name. Defaults to the class name.
alpha (float) – Significance level for analytical ATE confidence intervals. Passed through to
DoubleML.confint(level=1 - alpha).**kwargs (Any) – Keyword arguments forwarded to the DoubleML constructor (excluding
obj_dml_data). Typically includesml_l,ml_m,ml_g,n_folds, etc.
Examples
>>> from metacausal.adapters import DoubleMLAdapter >>> from doubleml import DoubleMLIRM >>> from sklearn.ensemble import ( ... HistGradientBoostingClassifier, HistGradientBoostingRegressor, ... ) >>> adapter = DoubleMLAdapter( ... DoubleMLIRM, ... alpha=0.10, ... ml_g=HistGradientBoostingRegressor(max_iter=200), ... ml_m=HistGradientBoostingClassifier(max_iter=200), ... )
Methods
__init__For binary outcomes, the IRM
ml_glearner must implementpredict_proba.Attributes
Details
- validate_outcome_type(detected)[source]¶
For binary outcomes, the IRM
ml_glearner must implementpredict_proba. DoubleMLIRM also requiresDoubleMLData(binary_outcome=True), which the adapter sets automatically at fit time when the detected outcome is binary.- Parameters:
detected (str)
- Return type:
None