Tutorials › Statistical Learning (Graduate) › Regularization and Stability of Stacking Weights

Ensemble Risk and Diversity · Tutorial 881 of 989

Regularization and Stability of Stacking Weights

See how simplex-constrained quadratic shrinkage stabilizes fitted stacking weights and what approximation bias it can introduce.

Advanced 12 min read

What You'll Learn

  • Define quadratic shrinkage of stacking weights toward uniform averaging on the simplex
  • Relate the penalty to the geometry and scale of the validation loss
  • Prove a perturbation bound for fitted weights and ensemble predictions
  • Translate weight stability into a bound on weight variability
  • Bound the risk cost of shrinking away from the best simplex mixture
  • Work through numerical examples of shrinkage, stability, and bias

Why Regularize Stacking Weights?

Stacking chooses weights by comparing candidate predictors on validation predictions, then combines their predictions using the fitted weights. When candidate predictors make similar predictions, the validation loss can be almost flat in some directions: quite different weight vectors may perform nearly equally on the observed data. In that situation, small changes in validation outcomes can produce large changes in the fitted weights. A penalty can stabilize the choice, but it may also move the ensemble away from the best-fitting mixture.

Here the weights are constrained to be nonnegative and sum to one. The regularizer we study is quadratic shrinkage toward uniform averaging. It favors balanced weights, while allowing the validation data to move the weights away from uniform when there is enough evidence to do so. The penalty parameter controls this tradeoff; its numerical meaning depends on the scale of the loss.

Definition: For \(M\) candidate predictors, the simplex of weights is \(\Delta_M=\{w\in\mathbb{R}^M:w_j\geq 0\text{ for every }j,\ \sum_{j=1}^M w_j=1\}\). Let \(u=(1/M,\ldots,1/M)^T\) be the uniform weight vector. Given validation responses \(y\in\mathbb{R}^n\) and a fixed prediction matrix \(A\in\mathbb{R}^{n\times M}\), define the quadratically regularized stacking weights as any minimizer \( \hat w_\lambda(y)\in\arg\min_{w\in\Delta_M}\{(1/(2n))\|y-Aw\|_2^2+(\lambda/2)\|w-u\|_2^2\}\), where \(\lambda\geq0\). The \(j\)th column of \(A\) contains validation predictions from candidate \(j\).

Because the weights sum to one, penalizing their squared norm is equivalent to shrinking toward uniform weights: \(\|w-u\|_2^2=\|w\|_2^2-1/M\). Thus a penalty on \(\|w\|_2^2\) and a penalty on squared distance from \(u\) give the same minimizer, up to an additive constant in the objective. The distance form makes the target of shrinkage explicit.

The simplex constraint matters. This penalty does not encourage sparse weights; among simplex vectors, it favors the most balanced vector, \(u\). If the validation loss supports a less balanced mixture, the fitted weights can still depart from \(u\). As \(\lambda\) grows, departures become more costly. At \(\lambda=0\), the solution is an unregularized constrained fit, which need not be unique. For \(\lambda>0\), the objective is strictly convex in \(w\), so the minimizer is unique.

What the Penalty Does to a Two-Predictor Mixture

Worked Example: Shrinking Two Weights Toward One Half

There are two candidate predictors with validation predictions \(1\) and \(0\) for one response, \(y=0.8\). Write \(w=(t,1-t)\), where the simplex constraint requires \(0\leq t\leq1\). The ensemble prediction is \(t\). With the squared-error objective and uniform shrinkage, the criterion is \( \frac12(0.8-t)^2+\frac{\lambda}{2}\{(t-0.5)^2+(1-t-0.5)^2\}=\frac12(0.8-t)^2+\lambda(t-0.5)^2.\)

Differentiating with respect to \(t\) gives \(t-0.8+2\lambda(t-0.5)=0\). The minimizer is therefore \( t_\lambda=\frac{0.8+\lambda}{1+2\lambda}.\) It lies between \(0.5\) and \(0.8\) for every \(\lambda>0\), so it is feasible and moves toward equal weights as the penalty increases.

At \(\lambda=0.5\), \(t_\lambda=1.3/2=0.65\), giving weights \((0.65,0.35)\). The validation squared error is \((0.8-0.65)^2=0.0225\). At \(\lambda=2\), \(t_\lambda=2.8/5=0.56\), giving weights \((0.56,0.44)\) and squared error \((0.8-0.56)^2=0.0576\). The unpenalized fit \(t=0.8\) has zero error on this one observation; the regularized fit accepts higher observed error in exchange for weights closer to uniform.

This example isolates the direction of shrinkage, but it does not imply that a larger penalty always improves prediction on new data. The validation loss is only an estimate of predictive performance. Regularization is useful when reduced sensitivity and variability are worth the possible increase in approximation error.

A Perturbation Bound for the Fitted Weights

For fixed validation predictions \(A\), the quadratic penalty makes the objective strongly convex even if the candidate predictions are highly correlated. Strong convexity provides a direct guarantee: changing the validation responses by a small amount cannot change the fitted weights arbitrarily much.

Theorem: Suppose \(A\) is fixed, \(\lambda>0\), and \(y,y'\in\mathbb{R}^n\). Let \(w=\hat w_\lambda(y)\) and \(w'=\hat w_\lambda(y')\). Then \( \|w-w'\|_2\leq\frac{\|A\|_{\mathrm{op}}}{n\lambda}\|y-y'\|_2,\) where \(\|A\|_{\mathrm{op}}=\sup_{\|v\|_2=1}\|Av\|_2\) is the operator norm. Consequently, \( \frac{\|A(w-w')\|_2}{\sqrt n}\leq\frac{\|A\|_{\mathrm{op}}^2}{n\lambda\sqrt n}\|y-y'\|_2.\)

Proof. Separate the objective into a common part \(g(w)=(1/(2n))\|Aw\|_2^2+(\lambda/2)\|w-u\|_2^2\) and a response-dependent linear term \(q_y^Tw\), where \(q_y=-A^Ty/n\). The gradient of \(g\) is \(\lambda\)-strongly monotone: for all \(v,w\), \( (\nabla g(v)-\nabla g(w))^T(v-w)=(1/n)\|A(v-w)\|_2^2+\lambda\|v-w\|_2^2\geq\lambda\|v-w\|_2^2.\)

A minimizer of a differentiable convex function over a convex set satisfies the variational inequality that its gradient has nonnegative inner product with every feasible displacement from that minimizer. Apply this to \(w\) with displacement \(w'-w\), and to \(w'\) with displacement \(w-w'\). Adding the resulting inequalities yields \( (\nabla g(w)-\nabla g(w'))^T(w-w')\leq(q_{y'}-q_y)^T(w-w').\) The left side is at least \(\lambda\|w-w'\|_2^2\). The Cauchy–Schwarz inequality bounds the right side above by \(\|q_{y'}-q_y\|_2\|w-w'\|_2\), and \(\|q_{y'}-q_y\|_2=\|A^T(y-y')/n\|_2\leq\|A\|_{\mathrm{op}}\|y-y'\|_2/n\). If \(w=w'\), the first claimed bound holds immediately; otherwise divide by \(\lambda\|w-w'\|_2\). Finally, \(\|A(w-w')\|_2\leq\|A\|_{\mathrm{op}}\|w-w'\|_2\), which gives the prediction bound. \(\square\)

The bound has two interpretable features. First, greater \(\lambda\) reduces sensitivity. Second, sensitivity also depends on \(\|A\|_{\mathrm{op}}\): changing the response matters more when the prediction columns collectively have a large scale. The penalty should therefore be interpreted relative to the scale of the loss and predictions, not as a scale-free tuning constant.

Worked Example: Flat Validation Loss and Weight Stability

Consider a two-weight mixture \(w=(t,1-t)\), and suppose the validation loss along this direction is \((c/2)(t-a)^2\), where \(a\) is the unregularized target and \(c>0\) measures curvature. Add the uniform penalty \(\lambda(t-0.5)^2\). Differentiating the objective gives \(c(t-a)+2\lambda(t-0.5)=0\), so \( t_\lambda=\frac{ca+\lambda}{c+2\lambda}.\)

Take \(a=0.9\), \(c=0.02\), and \(\lambda=0.03\). Then \(t_\lambda=(0.018+0.03)/(0.02+0.06)=0.6\). If the validation target changes from \(a=0.9\) to \(a=0.8\), the unpenalized fitted weight changes by \(0.1\). The regularized weight changes by \((c/(c+2\lambda))(0.1)=(0.02/0.08)(0.1)=0.025\). The factor \(0.25\) is exactly the derivative of \(t_\lambda\) with respect to \(a\). This small curvature represents a weakly identified weight contrast; the penalty substantially damps its response to the change in target.

Stability and Weight Variability

The perturbation result can also be read as a variability bound. Suppose \(Y\) is a random validation-response vector, \(A\) is fixed, and the fitted weights are \(W=\hat w_\lambda(Y)\). Assume \(E\|Y\|_2^2<\infty\). For an independent copy \(Y'\), let \(W'=\hat w_\lambda(Y')\). The identity \(E\|W-E[W]\|_2^2=\frac12E\|W-W'\|_2^2\) follows by expanding the squared norm and using independence. Applying the perturbation bound to \(Y,Y'\) then gives \(E\|W-E[W]\|_2^2\leq\frac{\|A\|_{\mathrm{op}}^2}{n^2\lambda^2}\operatorname{tr}\{\operatorname{Cov}(Y)\}.\)

Here \(\operatorname{tr}\{\operatorname{Cov}(Y)\}=E\|Y-E[Y]\|_2^2\). Thus, conditional on the fixed prediction matrix, quadratic shrinkage controls the total variance of the fitted weight vector. This is a bound, not an assertion that the weight variance always equals a constant times \(1/\lambda^2\); the actual variance may be much smaller, and the matrix scale and response variability matter.

The Approximation-Bias Cost

Stability is not free: a penalty can pull the weights away from the best mixture for the population risk. The next result makes that cost explicit. Let \(R(w)\) be a finite, continuous, convex population risk on \(\Delta_M\), and define \(w^*\) as a minimizer of \(R\) on the simplex. Define \(w_\lambda\) as a minimizer of \(R(w)+(\lambda/2)\|w-u\|_2^2\). These minimizers exist because the simplex is compact and the objectives are continuous.

Theorem: For \(\lambda\geq0\), the penalized population minimizer satisfies \(0\leq R(w_\lambda)-R(w^*)\leq\frac{\lambda}{2}\|w^*-u\|_2^2.\)

Proof. The lower bound follows because \(w^*\) minimizes \(R\) over the simplex and \(w_\lambda\in\Delta_M\). By the definition of \(w_\lambda\), its penalized objective is no greater than the value at the feasible point \(w^*\): \( R(w_\lambda)+\frac{\lambda}{2}\|w_\lambda-u\|_2^2\leq R(w^*)+\frac{\lambda}{2}\|w^*-u\|_2^2.\) Subtract \(R(w^*)\) and discard the nonnegative term \((\lambda/2)\|w_\lambda-u\|_2^2\) from the left. The result is the stated upper bound. \(\square\)

The bound is small when the best mixture is already close to uniform. It can be loose when the oracle weights are far from uniform, but it makes clear why the penalty target matters: quadratic shrinkage toward \(u\) is most benign when equal averaging is itself a good approximation.

Worked Example: Quantifying the Population Risk Cost

For two predictors, let the population risk at weights \((t,1-t)\) be \(R(t)=(t-0.8)^2\). Its minimum over \(0\leq t\leq1\) is \(R(0.8)=0\), so \(w^*=(0.8,0.2)\). The uniform vector is \(u=(0.5,0.5)\), and \(\|w^*-u\|_2^2=(0.3)^2+(-0.3)^2=0.18.\)

With \(\lambda=1\), the penalized risk is \((t-0.8)^2+(t-0.5)^2\). Setting its derivative \(2(t-0.8)+2(t-0.5)\) to zero gives \(t_\lambda=0.65\). Its population risk is \(R(0.65)=(0.15)^2=0.0225\). The theorem bounds this excess risk by \((1/2)(0.18)=0.09\), and indeed \(0.0225\leq0.09\). The shrinkage introduces some approximation bias, but its cost in this example is below the bound.

Practical Interpretation and a Common Pitfall

Quadratic shrinkage is useful when validation data do not reliably distinguish among several similar predictors or when weights vary substantially across plausible validation samples. It discourages extreme reweighting without changing the allowed class of simplex mixtures. In practice, choose \(\lambda\) on a scale compatible with the loss and use a validation design that avoids evaluating weights on the same in-sample predictions used to fit the candidate predictors.

  • Pitfall: treating the penalty as variance reduction with no cost. The incorrect reasoning is that more shrinkage always improves the ensemble because the fitted weights are more stable. Stability alone does not guarantee lower predictive risk; the population-risk result allows an excess-risk cost up to \((\lambda/2)\|w^*-u\|_2^2\).
  • Correction: assess the stability benefit alongside the possible approximation bias. A large penalty is most defensible when uniform weights are already a reasonable mixture, or when the unregularized fit is so unstable that its apparent validation advantage is not trustworthy.
  • Pitfall: assuming the same numerical \(\lambda\) has the same meaning for every problem. Multiplying the loss by a constant changes its scale relative to the penalty. Rescaling predictions or changing the loss normalization can therefore change the effective amount of shrinkage.

The key is not simply to make stacking weights smooth or balanced. It is to stabilize the weight contrasts that the validation data estimate weakly, while checking that the chosen shrinkage target does not impose too much approximation bias.

Check Your Understanding

Use the definitions and results above to answer these questions.

  1. Why does penalizing \(\|w\|_2^2\) give the same optimizer as penalizing \(\|w-u\|_2^2\) when the weights lie on the simplex?
  2. In the perturbation theorem, what happens to the weight-stability bound as \(\lambda\) increases, with \(A\) and \(n\) held fixed?
  3. For two predictors, derive the minimizer of \((c/2)(t-a)^2+\lambda(t-0.5)^2\) and state how its sensitivity to \(a\) depends on \(c\) and \(\lambda\).
  4. Under what condition on the oracle weights is the population excess-risk bound particularly small?
  5. Explain why reduced variability of fitted weights does not by itself prove that the ensemble's predictive risk has decreased.
Clinical Biostats