# econml.score.EnsembleCateEstimator

class econml.score.EnsembleCateEstimator(*, cate_models, weights)[source]

Bases: object

A CATE estimator that represents a weighted ensemble of many CATE estimators. Returns their weighted effect prediction.

Parameters
• cate_models (list of BaseCateEstimator objects) – A list of fitted cate estimator objects that will be used in the ensemble. The models are passed by reference, and not copied internally, because we need the fitted objects, so any change to the passed models will affect the internal predictions (e.g. if the input models are refitted).

• weights (np.ndarray of shape (len(cate_models),)) – The weight placed on each model. Weights must be non-positive. The ensemble will predict effects based on the weighted average predictions of the cate_models estiamtors, weighted by the corresponding weight in weights.

__init__(*, cate_models, weights)[source]

Methods

 __init__(*, cate_models, weights) Calculate the constant marginal CATE $$\theta(·)$$. effect([X, T0, T1]) Calculate the heterogeneous treatment effect $$\tau(X, T0, T1)$$. marginal_effect(T[, X]) Calculate the heterogeneous marginal effect $$\partial\tau(T, X)$$.

Attributes

 cate_models weights
const_marginal_effect(X=None)[source]

Calculate the constant marginal CATE $$\theta(·)$$.

The marginal effect is conditional on a vector of features on a set of m test samples X[i].

Parameters

X (optional (m, d_x) matrix or None (Default=None)) – Features for each sample.

Returns

theta – Constant marginal CATE of each treatment on each outcome for each sample X[i]. Note that when Y or T is a vector rather than a 2-dimensional array, the corresponding singleton dimensions in the output will be collapsed (e.g. if both are vectors, then the output of this method will also be a vector)

Return type

(m, d_y, d_t) matrix or (d_y, d_t) matrix if X is None

effect(X=None, *, T0=0, T1=1)[source]

Calculate the heterogeneous treatment effect $$\tau(X, T0, T1)$$.

The effect is calculated between the two treatment points conditional on a vector of features on a set of m test samples $$\{T0_i, T1_i, X_i\}$$.

Parameters
• T0 ((m, d_t) matrix or vector of length m) – Base treatments for each sample

• T1 ((m, d_t) matrix or vector of length m) – Target treatments for each sample

• X (optional (m, d_x) matrix) – Features for each sample

Returns

τ – Heterogeneous treatment effects on each outcome for each sample Note that when Y is a vector rather than a 2-dimensional array, the corresponding singleton dimension will be collapsed (so this method will return a vector)

Return type

(m, d_y) matrix

marginal_effect(T, X=None)[source]

Calculate the heterogeneous marginal effect $$\partial\tau(T, X)$$.

The marginal effect is calculated around a base treatment point conditional on a vector of features on a set of m test samples $$\{T_i, X_i\}$$.

Parameters
• T ((m, d_t) matrix) – Base treatments for each sample

• X (optional (m, d_x) matrix) – Features for each sample

Returns

grad_tau – Heterogeneous marginal effects on each outcome for each sample Note that when Y or T is a vector rather than a 2-dimensional array, the corresponding singleton dimensions in the output will be collapsed (e.g. if both are vectors, then the output of this method will also be a vector)

Return type

(m, d_y, d_t) array