API reference

One page per public class and function, generated from docstrings via sphinx.ext.autosummary. Each ## section below is a real import path (metacausal, metacausal.aggregation, …); each item is listed once, under the module it’s defined in.

Many aggregation-strategy and adapter classes (e.g. Median, CausalMLAdapter) are re-exported at the top level for convenience – from metacausal import Median works even though it’s documented under metacausal.aggregation below. See the Mixed-framework method list or metacausal.__all__ for the exact top-level surface.

metacausal

Top-level namespace: the ensemble class, its estimate/result types, and outcome-type detection.

metacausal.CausalEnsemble

Ensemble of causal estimators with robust aggregation.

metacausal.AteEstimate

Result from the ensemble of causal estimators.

metacausal.CateEstimate

Ensemble CATE result.

metacausal.ComponentAteEstimate

Result from a single causal estimator.

metacausal.ComponentCateEstimate

CATE result from a single component method.

metacausal.infer_outcome_type

Detect the outcome type from the values of Y.

Warnings

metacausal.MetaCausalWarning

Umbrella class for all metacausal-emitted warnings.

metacausal.ComponentWarning

Base class for warnings indicating an operating-ensemble pool reduction.

metacausal.ComponentFailureWarning

A component raised an exception during fit, cross-fitting, prediction, or as part of nuisance/weight-fitting machinery, and was silently excluded from the operating ensemble.

metacausal.ComponentExclusionWarning

A component was excluded by configuration mismatch.

metacausal.BootstrapWarning

A bootstrap inference call hit a reliability concern.

metacausal.aggregation

Aggregation strategies (combine component ATE/CATE predictions into an ensemble estimate) and the result types they produce.

metacausal.aggregation.AggregationStrategy

Abstract base class for all aggregation strategies.

metacausal.aggregation.PointwiseStrategy

Base class for strategies that apply a fixed statistical rule pointwise.

metacausal.aggregation.AgreementStrategy

Base class for strategies that select/weight models by inter-model agreement.

metacausal.aggregation.SupervisedStrategy

Base class for outcome-supervised aggregation strategies.

metacausal.aggregation.Mean

Pointwise mean aggregation.

metacausal.aggregation.Median

Pointwise median aggregation.

metacausal.aggregation.TrimmedMean

Pointwise trimmed-mean aggregation.

metacausal.aggregation.CBA

Consensus Based Averaging (Machluf et al., 2024).

metacausal.aggregation.CausalStacking

Causal Stacking (Han & Wu, 2022).

metacausal.aggregation.QAggregation

Doubly Robust Q-Aggregation (Lan & Syrgkanis, 2024).

metacausal.aggregation.RStacking

R-Stacking (Nie & Wager, 2021).

metacausal.aggregation.Select

Select the single component model minimizing a pseudo-outcome risk.

metacausal.aggregation.EnsembleWeights

Result of weight computation for any non-pointwise aggregation.

metacausal.aggregation.BootstrapResult

Bootstrap inference results for both ATE and CATE.

Cross-fitting

metacausal.aggregation.CrossFitSplit

Q-fold cross-fitting split.

metacausal.aggregation.TrainAvgSplit

Simple train / averaging-set split.

metacausal.aggregation.FoldSpec

Result of a data split: absolute indices into the original array per fold.

Nuisance estimation

metacausal.aggregation.NuisanceEstimates

Out-of-fold nuisance model predictions.

metacausal.aggregation.fit_nuisance

Fit nuisance models via cross-fitting and return out-of-fold predictions.

metacausal.aggregation.dr_pseudo_outcome

Compute the DR/AIPW pseudo-outcome for each observation.

metacausal.aggregation.robinson_residuals

Compute Robinson decomposition residuals.

metacausal.adapters

Wrappers presenting each supported library’s estimators (EconML, CausalML, DoubleML, stochtree) through one common interface, plus generic adapters for wrapping arbitrary user-supplied estimators.

metacausal.adapters.CausalEstimator

Protocol that all causal estimator adapters must satisfy.

metacausal.adapters.EconMLAdapter

Wrap an initialized-but-unfitted EconML estimator.

metacausal.adapters.CausalMLAdapter

Wrap a CausalML estimator as a metacausal causal estimator.

metacausal.adapters.DoubleMLAdapter

Wrap a DoubleML estimator class for use in CausalEnsemble.

metacausal.adapters.StochtreeAdapter

Wrap stochtree's BCFModel for use in CausalEnsemble.

metacausal.adapters.GenericATEAdapter

Wrap a callable fn(X, T, Y) -> float as an ATE-only causal estimator.

metacausal.adapters.GenericCATEAdapter

Wrap callables as a CATE-capable causal estimator.

metacausal.adapters.INNER_WORKER_ENV

Sentinel env var set inside every MetaCausal parallel worker.

metacausal.plots

Requires the plots extra (pip install "metacausal[plots]"). Each function is also available as a thin method on the class it plots – see the corresponding class above (e.g. BootstrapResult.forest()).

metacausal.plots.forest

Forest plot of per-component and ensemble ATEs.

metacausal.plots.weights

Bar chart of aggregation weights.

metacausal.plots.cate_profile

Ensemble CATE along one covariate, with optional bootstrap CI.

metacausal.plots.disagreement

Pairwise disagreement between component CATEs evaluated on X.

metacausal.datasets

metacausal.datasets.load_lalonde

Load the Lalonde job training dataset.