Tutorials › Statistical Learning (Graduate) › Randomized Gibbs Predictions and Deterministic Mixtures

Exponential Weights and Convex Aggregation · Tutorial 325 of 989

Randomized Gibbs Predictions and Deterministic Mixtures

Derive the exact risk of randomized Gibbs prediction and prove when a deterministic weighted mixture cannot have higher risk.

Advanced 9 min read

What You'll Learn

  • Define randomized Gibbs prediction and its conditional risk.
  • Derive why randomized risk is the Gibbs-weighted average of candidate risks for any integrable loss.
  • State the conditions under which a deterministic mixture of predictions is well-defined.
  • Prove that convexity of the loss makes the deterministic mixture no worse.
  • Identify why the comparison can fail for hard classification decisions.

Two Ways to Use Gibbs Weights

A Gibbs distribution over candidate predictors can be used in two different ways. One can draw a candidate at random and use that candidate's prediction, or average the candidates' predictions and use the average. These procedures are not the same: the first randomizes over whole candidate outputs, while the second forms a new prediction. Their risks are related, but a risk comparison requires conditions on the loss.

The weights may come from empirical losses and a temperature parameter, but the comparison below needs only a finite set of candidates and fixed weights. If the weights were estimated from training data, all statements can be read conditionally on that training data. This makes clear that the risk comparison concerns a fresh test observation, not the data used to construct the weights.

Definition: Let \(f_1,\ldots,f_M\) be measurable predictors and let \(w_1,\ldots,w_M\) be nonnegative weights with \(\sum_{j=1}^M w_j=1\). A randomized Gibbs prediction draws an index \(J\) with \(P(J=j)=w_j\) and returns \(f_J(x)\) at input \(x\). The deterministic mixture, when the prediction space is convex, returns \(\bar f(x)=\sum_{j=1}^M w_j f_j(x)\).

For example, Gibbs weights constructed from empirical candidate losses \(\widehat R_j\), a prior \(\pi_j\), and temperature \(\eta>0\) have the form \(w_j=\pi_j\exp(-\eta\widehat R_j)/\sum_{k=1}^M\pi_k\exp(-\eta\widehat R_k)\). Once the weights are specified, the identities and comparison in this tutorial do not depend on how they were obtained.

Risk of a Randomized Predictor

Let \(Z=(X,Y)\) be a fresh test observation, and let \(\ell(y,a)\) be the loss incurred when the response is \(y\) and the prediction is \(a\). Define the risk of candidate \(f_j\) by \(R(f_j)=E[\ell(Y,f_j(X))]\). Suppose the candidate losses are integrable, so these expectations exist and are finite. The random index \(J\) is drawn independently of \(Z\), conditional on any training data used to set the weights.

Proposition: For any loss satisfying the integrability condition above, the risk of randomized prediction is \(R_{\mathrm{rand}}=E[\ell(Y,f_J(X))]=\sum_{j=1}^M w_jR(f_j)\). No convexity assumption on the loss is required.

The identity follows by conditioning on the finite-valued index \(J\). In particular, randomization averages the candidates' losses, not their predictions:

$$ \begin{aligned} R_{\mathrm{rand}} &= \sum_{j=1}^M P(J=j)E[\ell(Y,f_j(X))\mid J=j]\\ &= \sum_{j=1}^M w_jE[\ell(Y,f_j(X))]\\ &= \sum_{j=1}^M w_jR(f_j). \end{aligned} $$

The second equality uses the conditional independence of \(J\) and the fresh test observation. If \(J\) is drawn once and the selected predictor is then used for many test observations, the same identity holds for the expected per-observation risk. The resulting losses across multiple observations need not be independent, since the same random choice is shared.

Worked Example: Computing Gibbs Weights and Randomized Risk

There are two candidates with prior weights \(\pi_1=\pi_2=1/2\), empirical losses \(\widehat R_1=0\) and \(\widehat R_2=\log 3\), and temperature \(\eta=1\). Their unnormalized Gibbs weights are \( (1/2)e^0=1/2\) and \( (1/2)e^{-\log 3}=1/6\). Their sum is \(2/3\), so the normalized weights are \(w_1=(1/2)/(2/3)=3/4\) and \(w_2=(1/6)/(2/3)=1/4\).

Suppose their risks on fresh observations are \(R(f_1)=2\) and \(R(f_2)=6\). The randomized risk is \(R_{\mathrm{rand}}=(3/4)2+(1/4)6=3/2+3/2=3\). This calculation is valid for any integrable loss; it does not require the predictions or loss to be convex.

When Averaging Predictions Helps

To compare the randomized predictor with the deterministic mixture, the prediction values must be averageable. Suppose, for each input \(x\), the predictions lie in a convex subset \(C\) of a real vector space, and the loss \(a\mapsto\ell(y,a)\) is convex on \(C\) for every response \(y\). Convexity means that for any \(a,b\in C\) and \(\lambda\in[0,1]\), \(\ell(y,\lambda a+(1-\lambda)b)\leq\lambda\ell(y,a)+(1-\lambda)\ell(y,b)\). Also assume the mixture loss is integrable. These conditions ensure that \(\bar f(x)\) is an admissible prediction and that its risk is defined.

Theorem: Under these conditions, \(R(\bar f)\leq R_{\mathrm{rand}}\). Thus a deterministic weighted mixture has risk no greater than the randomized prediction when the loss is convex in the prediction.

For completeness, the finite-weight inequality needed here follows directly from the definition of convexity. For fixed \(y\), we show \(\ell(y,\sum_{j=1}^M w_ja_j)\leq\sum_{j=1}^M w_j\ell(y,a_j)\) for \(a_j\in C\). The claim is immediate for one positive weight. For \(M\) positive weights, let \(s=\sum_{j=1}^{M-1}w_j\). If \(s=0\), the mixture is \(a_M\) and equality holds. If \(s>0\), set \(b=\sum_{j=1}^{M-1}(w_j/s)a_j\), which lies in \(C\). Applying convexity to \(sb+w_Ma_M\), and then applying the same claim to the first \(M-1\) normalized weights, gives

$$ \begin{aligned} \ell\left(y,\sum_{j=1}^M w_ja_j\right) &=\ell(y,sb+w_Ma_M)\\ &\leq s\ell(y,b)+w_M\ell(y,a_M)\\ &\leq \sum_{j=1}^{M-1}w_j\ell(y,a_j)+w_M\ell(y,a_M). \end{aligned} $$

Weights equal to zero can be discarded, so the argument covers all nonnegative weights summing to one. Apply this inequality with \(a_j=f_j(X)\) and \(y=Y\). Taking expectations preserves the inequality, and the randomized-risk identity then yields the result:

$$ \begin{aligned} R(\bar f) &=E\left[\ell\left(Y,\sum_{j=1}^M w_jf_j(X)\right)\right]\\ &\leq E\left[\sum_{j=1}^M w_j\ell(Y,f_j(X))\right]\\ &=\sum_{j=1}^M w_jR(f_j) =R_{\mathrm{rand}}. \end{aligned} $$

This argument is conditional on the training data if the weights and candidates depend on that data. Averaging the resulting conditional inequality over the training data gives the corresponding unconditional comparison, whenever the risks are integrable. \(\square\)

Worked Example: Squared Loss for Two Regression Predictions

Suppose the response is always \(Y=0\), and two candidates predict \(f_1(X)=0\) and \(f_2(X)=4\). Let \(w_1=3/4\) and \(w_2=1/4\), and use squared loss \(\ell(y,a)=(y-a)^2\).

The candidate risks are \(R(f_1)=(0-0)^2=0\) and \(R(f_2)=(0-4)^2=16\). Therefore the randomized risk is \((3/4)0+(1/4)16=4\). The deterministic mixture predicts \(\bar f(X)=(3/4)0+(1/4)4=1\), so its risk is \((0-1)^2=1\). The mixture is better here, as the theorem allows; the theorem guarantees no greater risk, not strict improvement in every problem.

Worked Example: Absolute Loss and a Different Mixture

Let \(Y=0\), with predictions \(f_1(X)=-2\) and \(f_2(X)=4\), weights \(w_1=2/3\) and \(w_2=1/3\), and absolute loss \(\ell(y,a)=|y-a|\). The candidate risks are \(2\) and \(4\), so the randomized risk is \((2/3)2+(1/3)4=4/3+4/3=8/3\).

The deterministic prediction is \((2/3)(-2)+(1/3)4=-4/3+4/3=0\), with absolute loss \(|0-0|=0\). The result is consistent with convexity of absolute loss in the prediction. It also illustrates that the mixture's prediction can lie between candidate values, even when neither candidate predicts that value.

What the Comparison Does—and Does Not—Say

The exact randomized-risk identity is broader than the deterministic-mixture guarantee. For a nonconvex loss, averaging predictions can increase loss, and a weighted average may not even be a meaningful prediction. The convexity condition concerns the loss as a function of the prediction, with the response held fixed. Convexity in some other argument does not establish the theorem.

Hard classification gives a useful warning. Suppose two classifiers predict labels \(1\) and \(0\), with weights \(0.6\) and \(0.4\), and the true label is \(0\). Under zero-one loss, randomized prediction has risk \(0.6(1)+0.4(0)=0.6\). A weighted vote chooses label \(1\), so its zero-one loss is \(1\), which is worse. The set of hard labels \(\{0,1\}\) is not convex as a prediction space, and zero-one loss as a function of a hard label does not provide the required convexity comparison. Averaging class scores or probabilities and then applying a decision rule is a different procedure; the theorem applies only if the resulting prediction and loss meet its stated conditions.

A related distinction is between averaging predictions and averaging risks. Randomized prediction averages the candidate risks exactly. The deterministic mixture first averages the prediction values, then evaluates the loss. Convexity is what permits the loss of that average to be bounded by the average loss; without it, the two operations cannot generally be interchanged.

Key takeaway: For any integrable loss, drawing a candidate from Gibbs weights has risk equal to the weighted average candidate risk. If predictions lie in a convex space and the loss is convex in prediction, averaging the predictions produces a deterministic predictor with no greater risk.

Check Your Understanding

Use the assumptions carefully: distinguish an identity that holds for general losses from a comparison that needs convexity.

  1. Why does the randomized-risk identity not require the loss to be convex?
  2. Two candidates have risks \(3\) and \(7\), with weights \(0.25\) and \(0.75\). What is the randomized risk?
  3. State the two conditions on the prediction space and loss that yield the deterministic-mixture risk guarantee.
  4. For squared loss, candidates predict \(1\) and \(5\), with equal weights, when \(Y=2\). Compute the randomized risk and the deterministic-mixture risk.
  5. Why does the convex-mixture result not automatically apply to a weighted vote of hard labels under zero-one loss?
Clinical Biostats