True and empirical risk of a loss #
A learning problem in the sense of [ShalevShwartzBenDavid2014, Section 3.2.2] consists of a set
W of hypotheses (or models), a domain Z of examples and a loss ℓ : W → Z → ℝ, where
ℓ w z is the loss of the hypothesis w on the example z. Classification is the case
Z = X × Y with the 0-1 loss, but the examples need not be labelled points. Given a probability
distribution D on Z, the true risk of w is its expected loss
L_D(w) = ∫ ℓ w z ∂D [ShalevShwartzBenDavid2014, (3.3)], and on a sample S = (z₁, …, z_m) its
empirical risk is the average loss L_S(w) = (1 / m) ∑ i, ℓ w (S i)
[ShalevShwartzBenDavid2014, (3.4)].
The source requires nonnegative losses; nothing here does. The true risk is a Bochner integral,
so it takes the junk value 0 when ℓ w is not integrable, and the results that integrate assume
integrability. The empirical risk on the empty sample is 0.
Convexity enters through the curried losses fun w => ℓ w z: if each is convex on a convex set
K, so is L_S and, for integrable losses, L_D. These are the objectives of regularized loss
minimization and of stochastic gradient descent.
Main definitions #
Cslib.MachineLearning.trueRisk: the true riskL_D(w).Cslib.MachineLearning.empiricalRisk: the empirical riskL_S(w).
Main results #
Cslib.MachineLearning.trueRisk_def,Cslib.MachineLearning.empiricalRisk_def: the defining equations; the definitions are not exposed.Cslib.MachineLearning.empiricalRisk_eq_sum_div: the empirical risk as a sum divided bym.Cslib.MachineLearning.empiricalRisk_update: replacing one example changes the empirical risk by the change in its loss divided bym.Cslib.MachineLearning.integral_empiricalRisk_comp: for a hypothesisA Schosen from the sample, the expected empirical risk is the average overiof the expected loss ofA SonS i.Cslib.MachineLearning.integral_empiricalRisk: for a fixed hypothesis, the empirical risk onm > 0i.i.d. examples is an unbiased estimate of the true risk.Cslib.MachineLearning.convexOn_empiricalRisk,Cslib.MachineLearning.convexOn_trueRisk: convex losses have convex risks.Cslib.MachineLearning.continuousOn_empiricalRisk,Cslib.MachineLearning.integrable_empiricalRisk_comp,Cslib.MachineLearning.measurable_empiricalRisk: continuity, integrability and measurability of the empirical risk follow from those of the losses.Cslib.MachineLearning.trueRisk_mem_Icc,Cslib.MachineLearning.empiricalRisk_mem_Icc: losses in[0, 1]have risks in[0, 1].
References #
Definitions #
The true risk L_D(w) = ∫ ℓ w z ∂D of a hypothesis w under a distribution D on
examples: the expected loss [ShalevShwartzBenDavid2014, (3.3)]. It is 0 when ℓ w is not
D-integrable.
The empirical risk L_S(w) = (1 / m) ∑ i, ℓ w (S i) of a hypothesis w on a sample S
of m examples: the average loss [ShalevShwartzBenDavid2014, (3.4)]. It is 0 on the empty
sample.
The empirical risk #
If every loss fun w => ℓ w (S i) is convex on K, the empirical risk on S is convex on
K.
If every loss fun w => ℓ w (S i) is continuous on K, so is the empirical risk on S.
Expected risks #
For a hypothesis A S chosen from the sample, the empirical risk of A S is integrable when
its loss on each example is.
For a hypothesis A S chosen from the sample S (under any sample distribution μ), the
expected empirical risk of A S is the average over i of the expected loss of A S on the
i-th example.
Unbiasedness of the empirical risk: for a fixed hypothesis w with D-integrable loss,
the expected empirical risk on m > 0 independent examples from a probability distribution D
is the true risk.
If every loss fun w => ℓ w z is convex on K and ℓ w is D-integrable for every
w ∈ K, the true risk is convex on K.
The empirical risk of w is measurable in the sample when the loss ℓ w is measurable.
A loss with values in [0, 1] has true risk in [0, 1] under a probability distribution.