Tutorials › Statistical Learning (Graduate) › Honest Leaf Estimation After Tree Construction

Partition-Based and Tree Estimators · Tutorial 808 of 989

Honest Leaf Estimation After Tree Construction

Separate tree construction from leaf estimation to obtain clear conditional guarantees for regression leaf means.

Intermediate 10 min read

What You'll Learn

  • Define an honest regression-tree leaf estimator using separate construction and estimation samples
  • Identify the precise cellwise target for which a leaf mean is conditionally unbiased
  • Derive its conditional variance and separate it from within-cell approximation bias
  • Account for random leaf counts and the probability of an empty leaf
  • Recognize why reusing outcomes to choose a tree can undermine these guarantees

Why Separate Tree Construction from Leaf Estimation?

A regression tree adapts its partition to the data: split locations and even the number of leaves may be chosen after examining the sample. That flexibility can make a leaf’s fitted mean optimistic if the same outcomes both selected the tree and estimated its leaf values. Honest estimation separates these tasks: one sample constructs the partition, and an independent sample estimates the values within its leaves.

The separation gives a precise conditional guarantee. Once the construction sample is held fixed, the partition is fixed too. The estimation observations that fall in any particular leaf can then be treated as a sample from the population restricted to that leaf. Their mean estimates the leaf’s population mean without bias. This is a statement about a cellwise target, not necessarily about the regression function at every point in the cell.

Definition and Conditional Targets

Definition: Let \(D_S\) be a construction sample and \(D_E=\{(X_i,Y_i):i=1,\ldots,n\}\) an estimation sample, independent of \(D_S\). Suppose the pairs in \(D_E\) are iid with the same distribution as a generic pair \((X,Y)\). A tree-building procedure using \(D_S\) produces a measurable partition \(\mathcal P(D_S)\) of the predictor space into leaves. For a leaf \(A\) with \(P(X\in A\mid D_S)>0\), define its population mean and variance by \(\mu_A=E[Y\mid X\in A,D_S]\) and \(\sigma_A^2=\operatorname{Var}(Y\mid X\in A,D_S)\). The honest leaf estimator is \(\hat\mu_A=N_A^{-1}\sum_{i=1}^n Y_i\mathbf 1\{X_i\in A\}\) when \(N_A>0\), where \(N_A=\sum_{i=1}^n\mathbf 1\{X_i\in A\}\).

Because \(D_E\) and \(D_S\) are independent and the population distribution is fixed, conditioning on \(D_S\) simply treats the realized leaf \(A\) as fixed. We assume \(E[Y^2]<\infty\), so the conditional means and variances used below exist whenever the cell has positive probability. We do not assign a value to \(\hat\mu_A\) when \(N_A=0\); any fallback rule for an empty leaf must be analyzed separately.

Write \(m(x)=E[Y\mid X=x]\), when a version of this conditional expectation is defined. The cell target is an average of the regression function over the predictor distribution in the leaf:

$$ \mu_A=E[m(X)\mid X\in A,D_S]. $$

This identity follows from iterated expectation. It also indicates an important distinction: unless \(m(x)\) is constant on \(A\), the target \(\mu_A\) need not equal \(m(x)\) for a particular \(x\in A\).

Worked Example: The Cellwise Target in a Two-Region Tree

Suppose \(X\) is uniform on \([0,1]\), and \(Y=X+\varepsilon\), where \(E[\varepsilon\mid X]=0\) and \(\operatorname{Var}(\varepsilon\mid X)=1\). A construction sample selects the split \(1/2\), giving the left leaf \(A=[0,1/2]\). Calculate its population target.

On this leaf, \(m(x)=E[Y\mid X=x]=x\). Conditional on \(X\in A\), \(X\) is uniform on \([0,1/2]\). Therefore \(\mu_A=E[X\mid X\leq 1/2]=(0+1/2)/2=1/4\). The leaf mean targets \(1/4\), not the value \(m(1/8)=1/8\) at \(x=1/8\).

For completeness, the variance of \(Y\) within the leaf is \(\sigma_A^2=\operatorname{Var}(X\mid X\leq1/2)+E[\operatorname{Var}(\varepsilon\mid X)\mid X\leq1/2]\), since the conditional noise mean is zero. A uniform variable on an interval of length \(1/2\) has variance \((1/2)^2/12=1/48\), so \(\sigma_A^2=1+1/48=49/48\). With exactly four estimation observations in this leaf, the honest leaf mean has conditional variance \((49/48)/4=49/192\).

Conditional Unbiasedness and Variance

Theorem: Under the conditions in the definition, fix a realized construction sample and a leaf \(A\) of positive probability. For any integer \(k\geq1\), \[ E[\hat\mu_A\mid D_S,N_A=k]=\mu_A,\qquad \operatorname{Var}(\hat\mu_A\mid D_S,N_A=k)=\frac{\sigma_A^2}{k}. \]

The conditioning on the count matters: these formulas describe the estimate when the leaf contains exactly \(k\) estimation observations. They do not assert that a leaf with no observations has an unbiased estimate.

Proof. Conditional on \(D_S\), the leaf \(A\) is fixed. Each estimation observation has probability \(p_A=P(X\in A\mid D_S)>0\) of landing in \(A\). Given that exactly \(k\) observations land there, the \(k\) responses associated with those observations have the conditional distribution of \(Y\) given \(X\in A,D_S\), independently. This follows from iid sampling: conditioning on which indices fall in \(A\) gives independent observations, each restricted to \(A\); the resulting distribution of their responses is the same for every possible set of \(k\) indices. Averaging over the possible index sets does not change the distribution of their sample mean.

Thus, under the stated conditioning, \(\hat\mu_A\) is the mean of \(k\) independent responses with mean \(\mu_A\) and variance \(\sigma_A^2\). Linearity of expectation gives \(E[\hat\mu_A\mid D_S,N_A=k]=k^{-1}(k\mu_A)=\mu_A\). Independence gives \(\operatorname{Var}(\hat\mu_A\mid D_S,N_A=k)=k^{-2}(k\sigma_A^2)=\sigma_A^2/k\).

The proof relies on the estimation sample being independent of the construction sample. It does not require the tree-building method to be simple or nonadaptive: conditional on \(D_S\), its realized partition is fixed. It does require that the outcomes in \(D_E\) have not been used to choose that partition.

Worked Example: Conditional Variance with a Noisy Regression Function

Within a fixed leaf, suppose \(X\) is uniform on \([0,1]\), \(Y=X+\varepsilon\), and \(\varepsilon\) is independent of \(X\) with mean zero and variance \(4\). If the leaf is \(A=[0,1]\) and exactly \(k=8\) estimation observations fall in it, find the target and the conditional variance of its honest mean.

The target is \(E[Y\mid X\in A]=E[X]+E[\varepsilon]=1/2\). For a uniform variable on \([0,1]\), \(\operatorname{Var}(X)=1/12\). Independence gives \(\operatorname{Var}(Y\mid X\in A)=\operatorname{Var}(X)+\operatorname{Var}(\varepsilon)=1/12+4=49/12\).

The theorem therefore gives \(\operatorname{Var}(\hat\mu_A\mid D_S,N_A=8)=(49/12)/8=49/96\), approximately \(0.5104\). The \(1/12\) part of the response variation comes from variation in the regression function across the leaf; the remaining \(4\) comes from noise. Both contribute to the variability of a leafwise sample mean.

Pointwise Prediction Error: Variance Plus Approximation Bias

A tree prediction is often evaluated at a particular predictor value \(x\), not against the leaf average. If \(x\in A\), then conditional on \(D_S\) and \(N_A=k\), the estimator still has mean \(\mu_A\). Its conditional mean squared error for predicting \(m(x)\) separates into a sampling-variance term and a squared difference between the cell target and the pointwise regression value.

Result: If \(m(x)\) is finite and \(x\in A\), then for \(k\geq1\), \[ E[(\hat\mu_A-m(x))^2\mid D_S,N_A=k] =\frac{\sigma_A^2}{k}+(\mu_A-m(x))^2. \]

Derivation. Add and subtract \(\mu_A\), then expand the square: \[ E[(\hat\mu_A-m(x))^2\mid D_S,N_A=k] =E[(\hat\mu_A-\mu_A)^2\mid D_S,N_A=k] +2(\mu_A-m(x))E[\hat\mu_A-\mu_A\mid D_S,N_A=k] +(\mu_A-m(x))^2. \] The middle term is zero by conditional unbiasedness. The first term is the conditional variance, \(\sigma_A^2/k\). Substitution gives the claimed identity. The second term is an approximation error from representing all points in a leaf by one constant; honesty removes neither this term nor the variation of \(m(x)\) within the leaf. \(\square\)

This decomposition helps keep two sources of error distinct. Increasing the number of estimation observations in a leaf reduces its sampling variance. Changing the partition can change both the cell variance and the gap between \(\mu_A\) and \(m(x)\). The latter is a property of the cell and regression function, not a failure of conditional unbiasedness.

Worked Example: Separating Estimation Error from Cell Approximation

Use the model \(X\sim\operatorname{Uniform}[0,1]\), \(Y=X+\varepsilon\) from the first example, with conditional noise variance \(1\). For the leaf \(A=[0,1/2]\), suppose exactly four estimation observations fall in the leaf. Calculate the conditional mean squared error for predicting \(m(1/8)\).

The cell target is \(\mu_A=1/4\), while \(m(1/8)=1/8\). The approximation bias is therefore \(1/4-1/8=1/8\), and its square is \(1/64\). The within-leaf response variance is \(49/48\), so the estimation variance with four observations is \(49/192\).

Adding the two terms gives \[ E[(\hat\mu_A-m(1/8))^2\mid D_S,N_A=4] =\frac{49}{192}+\frac{1}{64} =\frac{49}{192}+\frac{3}{192} =\frac{52}{192} =\frac{13}{48}. \] Thus the mean is unbiased for the leaf average, but it is not unbiased for the pointwise regression value at \(1/8\).

Random Leaf Counts and Empty Cells

Even with a fixed partition, \(N_A\) is random because estimation predictors are random. Conditional on \(D_S\), it has a binomial distribution with parameters \(n\) and \(p_A=P(X\in A\mid D_S)\). Consequently,

$$ P(N_A=0\mid D_S)=(1-p_A)^n. $$

An empty leaf makes the sample mean undefined. A procedure may discard the leaf, merge it, or use a fallback value, but the theorem does not give that fallback an unbiasedness guarantee. For a positive count, the variance decreases as \(1/N_A\). If we condition only on the event \(N_A>0\), then the estimate remains unbiased for \(\mu_A\), and its variance is \(\sigma_A^2 E[1/N_A\mid D_S,N_A>0]\). To see this, condition first on each possible positive count \(k\): the conditional mean is always \(\mu_A\) and the conditional variance is \(\sigma_A^2/k\), so averaging over \(k\) leaves the mean unchanged and averages those variances.

Worked Example: A Small Leaf with a Random Count

Suppose a fixed leaf has probability \(p_A=1/2\), there are \(n=4\) estimation observations, and the response variance within the leaf is \(\sigma_A^2=4\). Find the probability the leaf is empty and the variance of its mean conditional on being nonempty.

The count has distribution \(N_A\sim\operatorname{Binomial}(4,1/2)\), so \(P(N_A=0)=(1/2)^4=1/16\) and \(P(N_A>0)=15/16\). For \(k=1,2,3,4\), the binomial probabilities are \(4/16,6/16,4/16,1/16\). Hence \[ E[1/N_A\mid N_A>0] =\frac{(4/16)(1)+(6/16)(1/2)+(4/16)(1/3)+(1/16)(1/4)}{15/16} =\frac{103}{180}. \]

Therefore \(\operatorname{Var}(\hat\mu_A\mid N_A>0,D_S)=4(103/180)=103/45\), approximately \(2.289\). This is larger than the variance \(4/4=1\) conditional on \(N_A=4\), because most nonempty samples contain fewer than four observations. The nonempty conditioning matters: assigning zero to an empty leaf would generally introduce bias unless \(\mu_A=0\).

What Honesty Guarantees—and a Common Pitfall

Honest estimation is useful because its guarantees are conditional on the realized, possibly complicated partition. The construction sample can choose split locations, tree depth, and pruning decisions; the estimation sample then supplies the leaf means without also having determined which partition looked favorable. This separation makes the leafwise mean and variance calculations transparent.

A common mistake is to say, “The leaf mean is unbiased, so it estimates the regression function at every point in that leaf.” The first clause is true only for the cellwise target \(\mu_A\), conditional on the construction sample and a positive leaf count. The correction is that the pointwise target \(m(x)\) can differ from \(\mu_A\); the resulting discrepancy appears explicitly as \((\mu_A-m(x))^2\) in the conditional prediction error.

A related mistake is to select a split using estimation outcomes and then apply the conditional theorem as if the selected partition were fixed independently. Conditioning on a partition that was chosen using those same outcomes can change the conditional distribution of the leaf responses. The independence argument in the proof no longer applies. A separate estimation sample avoids this particular selection effect; it does not by itself ensure a good partition, eliminate approximation error, or solve the empty-leaf problem.

Key takeaway: Given the construction sample and a positive leaf count, an honest regression leaf mean estimates the population response mean within that leaf, with variance \(\sigma_A^2/N_A\). Prediction at an individual \(x\) also incurs the squared gap between that cell mean and \(m(x)\).

Check Your Understanding

Use the conditional targets and assumptions carefully when answering.

  1. State the population quantity for which an honest leaf mean is conditionally unbiased, and specify what it is conditioned on.
  2. For a leaf with response variance \(\sigma_A^2\) and exactly \(k\) estimation observations, what is the conditional variance of its mean?
  3. Why can an honest leaf mean be unbiased for its cell target but biased for \(m(x)\) at a point \(x\) in the leaf?
  4. If \(N_A\sim\operatorname{Binomial}(n,p_A)\), what is the probability that the leaf receives no estimation observations?
  5. Why does the conditional unbiasedness proof fail if the same outcomes are used both to select the tree and to estimate its leaf values?
Clinical Biostats