metacausal.adapters.DoubleMLAdapter

class metacausal.adapters.DoubleMLAdapter(model_class, name=None, alpha=0.05, **kwargs)[source]

Bases: object

Wrap 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. DoubleMLIRM or DoubleMLPLR.

  • 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 includes ml_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__

ate

cate

fit

validate_outcome_type

For binary outcomes, the IRM ml_g learner must implement predict_proba.

Attributes

Details

ate(X=None)[source]
Parameters:

X (ndarray | None)

Return type:

ComponentAteEstimate

cate(X)[source]
Parameters:

X (ndarray)

Return type:

ComponentCateEstimate

fit(X, T, Y, **kwargs)[source]
Parameters:
Return type:

None

validate_outcome_type(detected)[source]

For binary outcomes, the IRM ml_g learner must implement predict_proba. DoubleMLIRM also requires DoubleMLData(binary_outcome=True), which the adapter sets automatically at fit time when the detected outcome is binary.

Parameters:

detected (str)

Return type:

None

property name: str
property supports_cate: bool