Augmentation-style (AugForestRieszRegressor)
For each original row \(i = 1, \dots, n\), Estimand.augment emits the original observation \(Z_i\) and one evaluation point for each point at which the operator \(m\) evaluates the outcome regression \(\mu\) in \(m(\mu)(Z_i, Y_i)\), merging points that coincide. This gives \(M\) augmented rows in total. Each augmented row \(r\) carries an evaluation point \(z_r\), a weight \(D_r \in \{0, 1\}\) that is \(1\) exactly when \(z_r\) is the original observation, and a coefficient \(C_r\) equal to minus the sum of \(m\)’s coefficients on \(\mu(z_r)\) (\(C_r = 0\) when \(m\) does not evaluate \(\mu\) at \(z_r\)). For ATE, and for TSM on a row already at the target level, the original observation coincides with an evaluation point, so it carries \(D_r = 1\) and \(C_r = \pm 1\); the other evaluation points carry \(D_r = 0\) and \(C_r \ne 0\). Estimands works through the construction.
Each loss is generated by a convex, twice-differentiable function \(h\) with \(h'' > 0\) on the loss’s \(\alpha\)-domain, the set of values its \(\alpha\) may take (see Losses). Write \(h'\) and \(h''\) for its first two derivatives and \(\tilde h(t) = t\,h'(t) - h(t)\). The empirical Bregman-Riesz loss is
\[
\hat L(\alpha) \;=\; \frac{1}{n} \sum_{r=1}^M \big[\, D_r\, \tilde h(\alpha(z_r)) \;+\; C_r\, h'(\alpha(z_r)) \,\big].
\]
Its population counterpart is minimised at the Riesz representer \(\alpha_0\) (Losses). The sum runs over the \(M\) augmented rows, but they come from \(n\) observations, hence the \(1/n\). Grouped by original row \(i\), exactly one of its augmented rows has \(D_r = 1\), and by the definition of \(C_r\) its \(h'\) terms add up to \(-m(h' \circ \alpha)(Z_i, Y_i)\), so \(\hat L(\alpha) = \frac1n \sum_{i=1}^n \big[\tilde h(\alpha(Z_i)) - m(h' \circ \alpha)(Z_i, Y_i)\big]\).
SquaredLoss has \(h(t) = t^2\), so \(h'(t) = 2t\) and \(\tilde h(t) = t \cdot 2t - t^2 = t^2\). Each summand of \(\hat L\) is then \(D_r\, \alpha(z_r)^2 + 2 C_r\, \alpha(z_r)\).
Each tree partitions the feature space into leaves and predicts a single value \(\alpha\) for every point in leaf \(\ell\). With \(D_\ell = \sum_{r \in \ell} D_r\) and \(C_\ell = \sum_{r \in \ell} C_r\) summed over the augmented rows in the leaf, the leaf’s summands add up to \(\sum_{r \in \ell} \big[D_r\, \tilde h(\alpha) + C_r\, h'(\alpha)\big] = D_\ell\, \tilde h(\alpha) + C_\ell\, h'(\alpha)\). No two leaves share a value, so each leaf is optimised on its own, and the factor \(1/n\) does not move the minimiser. The leaf stores
\[
\hat\alpha_\ell \;=\; \arg\min_{\alpha \text{ in the }\alpha\text{-domain}} \big[\, D_\ell\, \tilde h(\alpha) \;+\; C_\ell\, h'(\alpha) \,\big].
\]
By the product rule, \(\tilde h'(t) = h'(t) + t\, h''(t) - h'(t) = t\, h''(t)\), so the derivative of the bracket is \(D_\ell\, \alpha\, h''(\alpha) + C_\ell\, h''(\alpha) = h''(\alpha)\,(D_\ell\, \alpha + C_\ell)\). Every leaf holds at least one original row (min_samples_leaf, at least 1, counts original rows), so \(D_\ell \ge 1\). Because \(h'' > 0\), the derivative has the sign of \(\alpha + C_\ell / D_\ell\): the bracket decreases up to \(-C_\ell / D_\ell\) and increases after it. When \(-C_\ell / D_\ell\) lies in the \(\alpha\)-domain it is the minimiser,
\[
\hat\alpha_\ell \;=\; -\,\frac{C_\ell}{D_\ell},
\]
and this formula is the same for every built-in loss. When \(-C_\ell / D_\ell\) falls outside the \(\alpha\)-domain, the bracket is monotone over the domain, so the minimum is at the nearest boundary. BoundedSquaredLoss(lo, hi) clips the leaf value to \([\mathrm{lo}, \mathrm{hi}]\); for the open domains of KLLoss (\(\alpha > 0\)) and BernoulliLoss (\(0 < \alpha < 1\)) the leaf stores the boundary value or a point just inside it. Tree backend has the details. The forest averages the per-tree predictions of \(\hat\alpha\).
The splitter can split on any feature, the treatment included, and each leaf value \(-C_\ell / D_\ell\) comes straight from the weights \(D_r\) and coefficients \(C_r\) of the augmented rows in the leaf. So the user does not supply any basis functions.
Moment-style (ForestRieszRegressor)
The user supplies a list of functions \(\varphi = (\varphi_1, \dots, \varphi_p)\) of the features \(z\). Within each leaf \(\ell\) the model is \(\alpha(z) = \theta^\top \varphi(z)\) for a coefficient vector \(\theta \in \mathbb R^p\). The forest is grown on the \(n\) original rows and splits on the columns in split_feature_indices (by default the covariates for ATE, ATT, and TSM, and every feature otherwise).
Only SquaredLoss is supported. With \(h(t) = t^2\), the row-grouped form of \(\hat L\) above says original row \(i\) contributes \(\alpha(Z_i)^2 - 2\, m(\alpha)(Z_i, Y_i)\). Because the operator \(m\) is linear, \(m(\theta^\top \varphi) = \theta^\top m(\varphi)\), where \(m(\varphi) = (m(\varphi_1), \dots, m(\varphi_p))\). Let \(n_\ell\) be the number of original rows in leaf \(\ell\) and \(\lambda \ge 0\) the l2 ridge (default \(0\)). Substituting \(\alpha = \theta^\top \varphi\), the leaf’s squared Riesz loss with the ridge penalty is
\[
\sum_{i\in\ell} \Big[\, \big(\theta^\top \varphi(Z_i)\big)^2 - 2\, \theta^\top m(\varphi)(Z_i, Y_i) \,\Big] \;+\; n_\ell\, \lambda\, \lVert\theta\rVert^2 .
\]
Write \(G_\ell = \sum_{i\in\ell} \varphi(Z_i)\,\varphi(Z_i)^{\top}\) for the leaf’s Gram matrix and \(b_\ell = \sum_{i\in\ell} m(\varphi)(Z_i, Y_i)\) for its moment sum. Since \(\sum_{i\in\ell} (\theta^\top \varphi(Z_i))^2 = \theta^\top G_\ell\, \theta\) and \(\sum_{i\in\ell} \theta^\top m(\varphi)(Z_i, Y_i) = \theta^\top b_\ell\), the loss is \(\theta^\top (G_\ell + n_\ell \lambda I)\, \theta - 2\, \theta^\top b_\ell\). The Gram matrix is a sum of outer products, so \(G_\ell + n_\ell \lambda I\) is positive semidefinite and the loss is convex in \(\theta\). Its gradient \(2\big[(G_\ell + n_\ell \lambda I)\,\theta - b_\ell\big]\) vanishes at the minimiser, so the leaf solves the linear-moment equation \((G_\ell + n_\ell \lambda I)\,\theta = b_\ell\). When \(G_\ell + n_\ell \lambda I\) is invertible (always when \(\lambda > 0\); when \(\lambda = 0\), exactly when the Gram matrix is),
\[
\hat\theta_\ell \;=\; \big(G_\ell + n_\ell\,\lambda I\big)^{-1} b_\ell .
\]
Splits use EconML’s "mse" criterion, which approximately chooses the split whose children’s leaf coefficients \(\hat\theta_\ell\) most lower this loss.
The forest does not average the per-tree leaf coefficients \(\hat\theta_\ell\). As in generalized random forests (GRF), it pools the leaf sums across trees. For a query point \(z\) and trees \(t = 1, \dots, T\), let \(\ell_t(z)\) be the leaf of tree \(t\) that contains \(z\), and give original row \(i\) the weight \(w_i(z) = \frac{1}{T} \sum_{t=1}^{T} \mathbf 1\{i \in \ell_t(z)\} / n_{\ell_t(z)}\). Here a leaf holds only the rows of its tree’s subsample (the estimation half when honest=True), and \(n_{\ell_t(z)}\) counts them. In each tree the indicator picks out the \(n_{\ell_t(z)}\) rows of \(z\)’s leaf, each weighted \(1/n_{\ell_t(z)}\), so they total \(1\); averaging over trees keeps the total at \(1\). The weights depend on \(z\) only through the split columns. The forest’s coefficient \(\hat\theta(z)\) solves the weighted version of the leaf equation (with a pseudo-inverse when the left side is singular),
\[
\Big(\sum_{i=1}^{n} w_i(z)\, \varphi(Z_i)\,\varphi(Z_i)^{\top} + \lambda I\Big)\, \hat\theta(z) \;=\; \sum_{i=1}^{n} w_i(z)\, m(\varphi)(Z_i, Y_i),
\]
and the prediction is \(\hat\alpha(z) = \hat\theta(z)^\top \varphi(z)\). With a single tree, \(w_i(z) = \mathbf 1\{i \in \ell\} / n_\ell\) for \(z\)’s leaf \(\ell\), and this equation is the leaf equation divided by \(n_\ell\), which is why the ridge appears as \(\lambda\) rather than \(n_\ell \lambda\).
The list \(\varphi\) has to be chosen per estimand. The default riesz_feature_fns="auto" picks defaults for built-in estimands:
ATE, ATT |
[1{A=0}, 1{A=1}] |
Forest splits on covariates only; the basis resolves treatment in each leaf. |
TSM(level=v) |
[1{A=v}] |
Single-basis fit; intervals supported. |
AdditiveShift, LocalShift, custom |
none — auto-resolution falls back to a constant function, which is row-degenerate |
Backend raises with a hint. Use AugForestRieszRegressor instead, or pass a custom list. |
For ATE with the default basis \(\varphi(a, x) = (\mathbf 1\{a = 0\}, \mathbf 1\{a = 1\})\), every row has \(m(\varphi)(Z_i, Y_i) = \varphi(1, X_i) - \varphi(0, X_i) = (0, 1) - (1, 0) = (-1, 1)\), so the moment sum is \(b_\ell = (-n_\ell, n_\ell)\). Each row’s \(\varphi(Z_i)\varphi(Z_i)^\top\) is \(\operatorname{diag}(1, 0)\) if untreated and \(\operatorname{diag}(0, 1)\) if treated, so the Gram matrix is \(G_\ell = \operatorname{diag}(n_{\ell,0},\, n_{\ell,1})\), where \(n_{\ell,0}\) and \(n_{\ell,1}\) count the untreated and treated rows in the leaf. Write \(\hat P(A = a \mid \ell) = n_{\ell,a} / n_\ell\) for the leaf’s share of rows with \(A = a\). With ridge \(\lambda = 0\) and both arms present in the leaf (\(n_{\ell,0}, n_{\ell,1} > 0\), so the Gram matrix is invertible), the leaf solve is \(\hat\theta_\ell = G_\ell^{-1} b_\ell = (-n_\ell / n_{\ell,0},\; n_\ell / n_{\ell,1})\); dividing each numerator and denominator by \(n_\ell\),
\[
\hat\theta_\ell \;=\; \Big(-\frac{1}{\hat P(A = 0 \mid \ell)},\; \frac{1}{\hat P(A = 1 \mid \ell)}\Big).
\]
Since \(\hat\alpha = \hat\theta_\ell^\top \varphi\) picks out the coordinate of the point’s arm, a treated point in the leaf gets \(\hat\alpha = 1/\hat P(A = 1 \mid \ell)\) and an untreated one gets \(-1/\hat P(A = 0 \mid \ell)\). The forest’s prediction follows from the same algebra with the weights \(w_i(z)\) in place of \(1/n_\ell\). Let \(\hat\pi(z) = \sum_i w_i(z)\, A_i\) be the forest-weighted share of treated rows. The weighted Gram matrix is \(\operatorname{diag}(1 - \hat\pi(z),\, \hat\pi(z))\) and the weighted moment sum is \((-1, 1)\), so \(\hat\alpha(1, x) = 1/\hat\pi(z)\) and \(\hat\alpha(0, x) = -1/(1 - \hat\pi(z))\). This is the inverse-propensity-weight representer \(\alpha_0(a, x) = a/\pi(x) - (1 - a)/(1 - \pi(x))\), with the propensity score \(\pi(x) = P(A = 1 \mid X = x)\) replaced by the forest-weighted treated share \(\hat\pi(z)\).