Tutorials › Statistical Learning (Graduate) › Weighted Risks for Unequal Observation Costs

Losses, Risks, and Regret · Tutorial 44 of 989

Weighted Risks for Unequal Observation Costs

Learn how observation weights change risk calculations, how normalization affects their scale, and when two weighted-risk conventions give the same comparison.

Beginner 10 min read

What You'll Learn

  • Define empirical weighted risk for a finite sample with nonnegative weights.
  • Distinguish a weighted sum from a weighted average and identify their scale difference.
  • Define population weighted risk and the conditions needed for a normalized version.
  • Interpret normalized population weighting as expectation under a reweighted distribution.
  • Calculate when weights reverse a finite-sample comparison between predictors.
  • Recognize why multiplying all weights by the same positive constant does not change a minimizer.

Why Weight Observations?

The usual empirical risk gives every observed case the same contribution. That is appropriate when all cases are meant to count equally. In some settings, however, observations have different importance or represent different amounts of the population. A weighted risk lets the analyst specify how strongly each observed case contributes, while retaining the same loss function for each case.

Weights affect the comparison being made: a model that performs well on highly weighted observations can be preferred even if its average loss across the sample is larger. It is therefore important to state both the weights and the normalization convention. Normalization changes the numerical scale of risk, but, when the same positive weights are used to compare all predictors, it does not change which predictors minimize it.

Empirical Weighted Risk

Suppose the observed data are \(z_1,\ldots,z_n\), a predictor or decision rule is \(h\), and the loss on observation \(z_i\) is \(\ell(h,z_i)\). Assign observation \(i\) a fixed weight \(a_i\geq 0\). The weights are not all zero.

Definition: The unnormalized empirical weighted risk is $$ \widehat R_{a}^{\,\mathrm{raw}}(h)=\frac{1}{n}\sum_{i=1}^n a_i\ell(h,z_i). $$ The normalized empirical weighted risk is $$ \widehat R_{a}^{\,\mathrm{norm}}(h)=\frac{\sum_{i=1}^n a_i\ell(h,z_i)}{\sum_{i=1}^n a_i}. $$ The normalized definition requires \(\sum_i a_i>0\), as assumed here.

The first convention divides by the sample size \(n\); the second divides by the total weight. If all weights equal one, both reduce to the ordinary empirical average. In general, \(\widehat R_{a}^{\,\mathrm{raw}}(h)=(\sum_i a_i/n)\widehat R_{a}^{\,\mathrm{norm}}(h)\). Thus the two conventions have different scales, but their ratio is constant across predictors for a fixed data set and fixed weights.

Worked Example: Weights Reverse an Empirical Comparison

There are three observations, and two predictors have the following losses. The observation weights are \(a=(1,3,0)\).

ObservationWeightLoss of \(h_A\)Loss of \(h_B\)
1102
2341
3013

The ordinary empirical risks are \(\widehat R(h_A)=(0+4+1)/3=5/3\) and \(\widehat R(h_B)=(2+1+3)/3=2\), so the unweighted comparison favors \(h_A\).

For the weighted risks, the weighted loss totals are \(1(0)+3(4)+0(1)=12\) for \(h_A\) and \(1(2)+3(1)+0(3)=5\) for \(h_B\). The normalized weighted risks are therefore \(12/(1+3+0)=3\) and \(5/4=1.25\), respectively. The weighted comparison favors \(h_B\). The third observation contributes nothing because its weight is zero.

Under the unnormalized convention, the risks are \(12/3=4\) and \(5/3\). These values differ in scale from the normalized risks, but the preferred predictor is still \(h_B\).

Population Weighted Risk

For a random observation \(Z\) with distribution \(F\), let \(w(Z)\) be a measurable, nonnegative weight and let \(\ell(h,Z)\) be the loss. The weight may be specified directly as a function of the observation, or may be a recorded nonnegative quantity associated with it. The population definition must distinguish the weighted expectation from the weighted average.

Definition: If \(E[w(Z)\ell(h,Z)]\) exists, the unnormalized population weighted risk is $$ R_w^{\,\mathrm{raw}}(h)=E[w(Z)\ell(h,Z)]. $$ If \(0<E[w(Z)]<\infty\), the normalized population weighted risk is $$ R_w^{\,\mathrm{norm}}(h)=\frac{E[w(Z)\ell(h,Z)]}{E[w(Z)]}, $$ provided the numerator is finite.

For an unnormalized risk, finiteness of the weighted expectation is needed to obtain a finite numerical value. For a normalized finite risk, both a finite, strictly positive expected weight and a finite weighted loss expectation are required. Nonnegative weights ensure that the contributions do not cancel one another. A weight of zero removes an observation from the weighted objective; it does not change that observation’s loss.

Worked Example: Raw and Normalized Population Risks

Let \(Z\) take values \(z_1,z_2\) with probabilities \(3/4\) and \(1/4\). Assign weights \(w(z_1)=1\) and \(w(z_2)=5\). Suppose predictor \(h_A\) has losses 0 and 4 at these points, while \(h_B\) has losses 2 and 1.

For \(h_A\), the unnormalized weighted risk is \(E[w(Z)\ell(h_A,Z)]=(3/4)(1)(0)+(1/4)(5)(4)=0+5=5\). The expected weight is \(E[w(Z)]=(3/4)(1)+(1/4)(5)=3/4+5/4=2\), so its normalized weighted risk is \(5/2=2.5\).

For \(h_B\), the unnormalized weighted risk is \((3/4)(1)(2)+(1/4)(5)(1)=3/2+5/4=11/4=2.75\). Its normalized weighted risk is \((11/4)/2=11/8=1.375\). Both weighted conventions favor \(h_B\).

Without weights, the risks are \(E[\ell(h_A,Z)]=(3/4)(0)+(1/4)(4)=1\) and \(E[\ell(h_B,Z)]=(3/4)(2)+(1/4)(1)=7/4=1.75\), favoring \(h_A\). The weighting changes the comparison. The raw weighted risk for \(h_A\) is 5; the value 2.5 is its normalized weighted risk, not the raw one.

Normalized Weighting as a Change of Distribution

When \(0<E[w(Z)]<\infty\), normalized weighting has a precise population interpretation. It defines a new distribution that gives relatively more probability to observations with larger weights. For a measurable set \(A\), define \(Q(A)=E[w(Z)\mathbf{1}_{\{Z\in A\}}]/E[w(Z)]\).

Theorem: If \(w(Z)\geq 0\) is measurable and \(0<E[w(Z)]<\infty\), then \(Q\) defined above is a probability distribution. For every nonnegative measurable function \(g\), $$ E_Q[g(Z)]=\frac{E[w(Z)g(Z)]}{E[w(Z)]}. $$ Consequently, whenever the weighted expectation is finite, normalized population weighted risk is the ordinary expected loss under \(Q\).

Proof. For every measurable \(A\), \(Q(A)\geq0\). Also, \(Q(\Omega)=E[w(Z)\mathbf{1}_{\{Z\in\Omega\}}]/E[w(Z)]=E[w(Z)]/E[w(Z)]=1\). If \(A_1,A_2,\ldots\) are pairwise disjoint measurable sets, their indicators sum to the indicator of their union. By monotone convergence for the nonnegative functions \(w(Z)\mathbf{1}_{\{Z\in\cup_j A_j\}}\), it follows that \(Q(\cup_j A_j)=\sum_j Q(A_j)\). Hence \(Q\) is a probability distribution.

For a nonnegative simple function \(g=\sum_{j=1}^m c_j\mathbf{1}_{A_j}\), with disjoint measurable \(A_j\) and \(c_j\geq0\), linearity gives \(E_Q[g]=\sum_j c_jQ(A_j)=E[w(Z)g(Z)]/E[w(Z)]\). For any nonnegative measurable \(g\), there is an increasing sequence of nonnegative simple functions converging pointwise to \(g\). Applying the simple-function identity and then the monotone convergence theorem under both distributions gives the same identity for \(g\). Taking \(g(Z)=\ell(h,Z)\), when the weighted expectation is finite, proves the risk statement. \(\square\)

This interpretation also clarifies what a weight does: normalized weighting changes the distribution against which loss is averaged. It does not, by itself, replace the loss function. Different applications may motivate different weights, so the weighting rule should be reported rather than treated as an inconsequential computational detail.

What Normalization Does—and Does Not—Change

Theorem: Fix observations \(z_1,\ldots,z_n\), nonnegative weights \(a_i\) with \(A=\sum_i a_i>0\), and a collection \(\mathcal H\) of predictors. The minimizers over \(\mathcal H\) of the unnormalized and normalized empirical weighted risks are identical.

Proof. For every \(h\in\mathcal H\), \(\widehat R_{a}^{\,\mathrm{raw}}(h)=(A/n)\widehat R_{a}^{\,\mathrm{norm}}(h)\). The multiplier \(A/n\) is strictly positive and does not depend on \(h\). Therefore, for any \(h_1,h_2\in\mathcal H\), \(\widehat R_{a}^{\,\mathrm{raw}}(h_1)\leq\widehat R_{a}^{\,\mathrm{raw}}(h_2)\) if and only if \(\widehat R_{a}^{\,\mathrm{norm}}(h_1)\leq\widehat R_{a}^{\,\mathrm{norm}}(h_2)\). The ordering of all predictors, including ties, is the same, so their minimizing sets are identical. \(\square\)

The same reasoning applies to population risk when \(0<E[w(Z)]<\infty\): normalized risk is unnormalized risk multiplied by the same positive constant \(1/E[w(Z)]\) for every predictor. This invariance is about comparing predictors under a fixed weighting scheme. It does not say that changing the weights leaves the comparison unchanged.

Worked Example: Rescaling Weights and Ignoring a Zero-Weight Case

Suppose four observations have losses \(0,3,2,8\) for a predictor \(h_A\), and \(2,1,4,0\) for \(h_B\). Let the weights be \((2,0,1,1)\), whose total is 4.

For \(h_A\), the weighted total is \(2(0)+0(3)+1(2)+1(8)=10\), giving normalized risk \(10/4=2.5\). For \(h_B\), the weighted total is \(2(2)+0(1)+1(4)+1(0)=8\), giving normalized risk \(8/4=2\). Thus \(h_B\) has lower weighted risk.

Now multiply every weight by 3, obtaining \((6,0,3,3)\). The weighted totals become 30 and 24, and the total weight is 12. The normalized risks remain \(30/12=2.5\) and \(24/12=2\). The unnormalized risks, using \(n=4\), change from \(10/4=2.5\) and \(8/4=2\) to \(30/4=7.5\) and \(24/4=6\), but the comparison remains the same. The second observation remains excluded because its weight is zero.

Common Mistakes

  • Mixing the two denominators. A weighted sum divided by \(n\) is not generally a weighted average. Divide by \(\sum_i a_i\) for the normalized empirical risk.
  • Assuming weights only change scale. Multiplying every weight by the same positive constant changes only scale. Changing the relative weights can change which predictor has lower risk, as the first worked example shows.
  • Forgetting to check the denominator. Normalization is undefined if all empirical weights are zero; at the population level, it requires \(E[w(Z)]>0\).
  • Confusing observation weighting with a changed loss. Weighted risk multiplies the loss contribution of an observation by its weight. It does not, by that operation alone, assign a different loss to each kind of error.
Key takeaway: State whether a weighted risk is a weighted sum or a weighted average. For fixed nonnegative weights with positive total, the normalization convention changes the scale but not the ranking of predictors; changing relative weights can change that ranking.

Check Your Understanding

Use the definitions and calculations above to answer these questions.

  1. For losses \(1,4,2\) and weights \(1,2,0\), calculate both the normalized and unnormalized empirical weighted risks, taking \(n=3\).
  2. Why does multiplying all positive-total observation weights by the same positive constant leave the minimizing predictors unchanged?
  3. For population weights \(w(Z)\), what conditions are needed to define a finite normalized weighted risk?
  4. Explain how normalized population weighting can be interpreted in terms of a new probability distribution.
  5. Can changing relative observation weights reverse a model comparison? Give the calculation or reasoning that supports your answer.
Clinical Biostats