metacausal.aggregation.SupervisedStrategy

class metacausal.aggregation.SupervisedStrategy(split=<factory>, propensity_model=None, outcome_model=None, propensity_trim=0.01, fit_nuisance_fn=None)[source]

Bases: AggregationStrategy

Base class for outcome-supervised aggregation strategies.

Weights are learned by optimizing a causal loss on outcome data, using out-of-fold CATE predictions and nuisance model estimates. Subclasses implement fit_weights().

ATE is computed as the mean of the ensemble CATE (same as AgreementStrategy). ATE-only adapters (supports_cate=False) are excluded from both CATE and ATE computation when this strategy is active.

Parameters:
  • split (CrossFitSplit or TrainAvgSplit) – Data splitting strategy for cross-fitting. Default: 5-fold cross-fitting.

  • propensity_model (sklearn classifier or None) – Model for P(T=1|X). Default: HistGradientBoostingClassifier (from defaults.py).

  • outcome_model (sklearn regressor / classifier or None) – Model for E[Y|X,T]. For continuous Y, must be a regressor; for binary Y, must be a classifier with predict_proba. None (default) selects an outcome-type-appropriate default at fit time.

  • propensity_trim (float) – Clip propensity scores to [trim, 1-trim] to enforce overlap.

  • fit_nuisance_fn (callable or None) –

    Optional replacement for the default fit_nuisance function. Must have the same signature:

    fit_nuisance_fn(X, T, Y, fold_spec,
                    propensity_model, outcome_model,
                    propensity_trim, random_state,
                    outcome_type) -> NuisanceEstimates
    

    outcome_type is the resolved value ("continuous" or "binary") the ensemble has decided for this fit; respect it when choosing whether to call predict() or predict_proba().

    Use this to inject BART-based nuisance, a single pooled outcome model with T as a feature, or any other custom nuisance pipeline. None (default) uses the standard two-model cross-fitted procedure.

Methods

__init__

aggregate

Aggregate component CATEs using stored weights.

fit_weights

Compute ensemble weights from OOF predictions and nuisance estimates.

Attributes

Details

aggregate(values)[source]

Aggregate component CATEs using stored weights.

Parameters:

values (array of shape (K, n))

Returns:

Array of shape (n,).

Return type:

ndarray

abstractmethod fit_weights(cate_predictions, Y, T, X, nuisance)[source]

Compute ensemble weights from OOF predictions and nuisance estimates.

Parameters:
  • cate_predictions (array of shape (K, m)) – Out-of-fold CATE predictions. m = n for CrossFitSplit; m = len(averaging set) for TrainAvgSplit.

  • Y (arrays of shape (m,), (m,), (m, p)) – Outcome, treatment, and covariates for the same m observations.

  • T (arrays of shape (m,), (m,), (m, p)) – Outcome, treatment, and covariates for the same m observations.

  • X (arrays of shape (m,), (m,), (m, p)) – Outcome, treatment, and covariates for the same m observations.

  • nuisance (NuisanceEstimates) – Out-of-fold nuisance predictions for the same m observations.

Returns:

EnsembleWeights with optimized weights.

Return type:

EnsembleWeights

property ensemble_weights: EnsembleWeights | None

Ensemble weights computed during fit(). None before fit().

fit_nuisance_fn: Any = None
outcome_model: Any = None
propensity_model: Any = None
propensity_trim: float = 0.01
split: CrossFitSplit | TrainAvgSplit
strategy_family: ClassVar[str] = 'supervised'