Why the Boundary Matters
Log loss is often introduced for forecasts that assign a positive probability to every class. But a true conditional distribution need not do so: given some information, an outcome may be impossible, or may occur with probability one. The distinction between allowing zero forecast probabilities and forbidding them then matters. With the closed probability simplex, the true conditional probabilities can be a valid minimizer. With the open simplex, that same optimum may be approached arbitrarily closely but never attained.
This is not a failure of log loss to identify the correct probabilities. It is a consequence of restricting the set of forecasts. To see precisely where that restriction bites, consider a finite set of \(K\ge 2\) classes.
Conditional Log Risk on the Simplex
Write \(p=(p_1,\ldots,p_K)\) for the conditional class-probability vector and \(q=(q_1,\ldots,q_K)\) for a forecast. Both have nonnegative coordinates summing to one. If the outcome is class \(j\), log loss is \(-\log q_j\), with \(-\log 0=+\infty\). The conditional expected loss is
In this sum, a term with \(p_j=0\) is defined to be zero, even if \(q_j=0\). Such a class has zero probability under the conditional distribution, so its loss does not contribute to the expectation. In contrast, if \(p_j>0\) and \(q_j=0\), then \(R_p(q)=+\infty\): the forecast assigns zero probability to an outcome that can occur.
Define the entropy of \(p\) by \(H(p)=-\sum_{j:p_j>0}p_j\log p_j\). It is finite for a finite number of classes. The conditional regret of \(q\) relative to \(p\) is \(R_p(q)-H(p)\). When this regret is finite, it equals the Kullback–Leibler divergence from \(p\) to \(q\), with zero-probability coordinates omitted from the sum.
Worked Example: A Deterministic Binary Outcome
Suppose there are two classes and \(p=(0,1)\). Write a forecast as \(q=(a,1-a)\). The only class with positive conditional probability is class 2, so
where the first term is zero by convention. On the closed simplex, \(a=0\) is allowed and gives \(R_p((0,1))=-\log 1=0\). On the open simplex, \(a>0\); then \(1-a<1\), so \(-\log(1-a)>0\). As \(a\) decreases to zero, the risk approaches zero, but no open-simplex forecast has risk zero. The same conditional distribution therefore has an attained minimum on the closed simplex and only an unattained infimum on the open simplex.
The Closed-Simplex Result
The claim includes boundary vectors \(p\). In particular, if a class is impossible, placing zero probability on it is permitted and can be part of the optimal forecast. The proof also establishes that assigning probability to impossible classes cannot improve the risk.
If \(q_j=0\) for some \(j\) with \(p_j>0\), then the corresponding term is \(+\infty\). Otherwise, the risk is finite and can be compared with entropy.
For a finite-risk forecast, subtracting \(H(p)\) gives \(\sum_{j:p_j>0}p_j\log(p_j/q_j)\).
Apply \(\log t\le t-1\) to \(t=q_j/p_j\), and check when equality can hold.
Proof. Let \(S=\{j:p_j>0\}\). If a coordinate in \(S\) has \(q_j=0\), the result follows from infinite risk. Otherwise,
For every \(t>0\), \(\log t\le t-1\), with equality exactly at \(t=1\). Therefore
Thus \(R_p(q)\ge H(p)\). If equality holds throughout, the last inequality requires \(\sum_{j\in S}q_j=1\), and equality in each logarithm inequality requires \(q_j/p_j=1\) for every \(j\in S\). Hence \(q_j=p_j\) on \(S\), and no probability remains for coordinates outside \(S\). Thus \(q=p\). Conversely, \(q=p\) has risk \(H(p)\), proving both attainment and uniqueness. \(\square\)
Worked Example: An Interior Binary Probability
Let \(p=(0.3,0.7)\), and write \(q=(u,1-u)\) for \(0<u<1\). The conditional risk is
Its derivative is \(-0.3/u+0.7/(1-u)\). Setting this equal to zero gives \(0.7u=0.3(1-u)\), hence \(u=0.3\). The second derivative, \(0.3/u^2+0.7/(1-u)^2\), is strictly positive for \(0<u<1\), so this is the unique minimum. The forecast \(q=p\) is in the open simplex, and its risk is
For comparison, the forecast \(q=(0.5,0.5)\) has risk \(-0.3\log(0.5)-0.7\log(0.5)=\log 2\approx0.693147\), which is higher by about \(0.082283\). Unlike the deterministic example, the open-simplex restriction causes no attainment problem here: the true probabilities are already strictly positive.
What Changes on the Open Simplex?
For an interior \(p\), the closed-simplex minimizer is itself an allowed open-simplex forecast. For a boundary \(p\), that minimizer is excluded. To see that the infimum is still \(H(p)\), let \(u=(1/K,\ldots,1/K)\) be the uniform vector and, for \(0<\varepsilon<1\), define
Every coordinate of \(q_\varepsilon\) is positive, so \(q_\varepsilon\in\Delta_K^\circ\). For \(j\in S=\{j:p_j>0\}\), \(q_{\varepsilon,j}\ge(1-\varepsilon)p_j\). Combining this bound with the closed-simplex result gives
The upper bound tends to zero as \(\varepsilon\) decreases to zero. Thus the open-simplex infimum is \(H(p)\). If \(p\) is on the boundary, no open-simplex vector equals \(p\); by the uniqueness proved above, every open-simplex forecast has risk strictly greater than \(H(p)\). The infimum is therefore not attained. If \(p\) is interior, the same uniqueness result applies and \(q=p\) attains the minimum. \(\square\)
Worked Example: Approaching a Multiclass Boundary
Take three classes and \(p=(1,0,0)\). The closed-simplex optimum is \(q=p\), with risk \(H(p)=0\). The smoothed open-simplex forecast is \(q_\varepsilon=(1-2\varepsilon,\varepsilon,\varepsilon)\), for \(0<\varepsilon<1/2\). Its only positive-risk contribution comes from class 1:
For \(\varepsilon=0.05\), this is \(-\log(0.9)\approx0.105361\). As \(\varepsilon\) decreases to zero, the risk approaches zero. But every open-simplex forecast must assign positive probability to classes 2 and 3, so it cannot equal \((1,0,0)\), and its risk is strictly positive. The optimal risk is an infimum, not a minimum, under this restriction.
Conditional Probabilities That Depend on Features
In prediction, the probability vector typically depends on observed features \(X\). Let \(p(X)\) be a measurable version of the conditional class-probability vector, and let \(q(X)\) be a measurable forecast. The expected log risk is the expectation of the conditional risk \(R_{p(X)}(q(X))\). Pointwise, its lowest possible value is \(H(p(X))\).
If forecasts may use the closed simplex, choosing \(q(X)=p(X)\) attains that value. If forecasts must lie in the open simplex, smoothing \(p(X)\) toward the uniform vector gives open-simplex forecasts. The bound just proved holds at every feature value:
Taking expectations preserves the bound, so these forecasts approach the expected conditional entropy. If \(p(X)\) lies on the boundary with positive probability, however, no open-simplex forecast attains that optimum: on those feature values its conditional risk is strictly larger. A nonnegative measurable gap that is strictly positive on a set of positive probability has strictly positive expectation (possibly infinite). If boundary values occur only on a probability-zero set, the restriction need not prevent attainment: a forecast can equal \(p(X)\) almost surely and be modified on that null set to be strictly positive.
Worked Example: Nonattainment on a Positive-Probability Feature Set
Let \(X\) take values 0 and 1, each with probability \(1/2\). At \(X=0\), suppose \(p(X)=(1,0)\); at \(X=1\), suppose \(p(X)=(0.5,0.5)\). The expected minimum conditional risk is
Using \(q_\varepsilon(X)=(1-\varepsilon)p(X)+\varepsilon(0.5,0.5)\), choose \(\varepsilon=0.2\). At \(X=0\), the forecast is \((0.9,0.1)\), giving risk \(-\log(0.9)\approx0.105361\). At \(X=1\), it remains \((0.5,0.5)\), giving risk \(\log 2\approx0.693147\). The expected risk is therefore
As \(\varepsilon\) tends to zero, this risk approaches \(0.346574\). But \(X=0\) occurs with positive probability, and there the open-simplex forecast cannot equal \((1,0)\). Every such forecast has a strictly positive excess risk on that event, so none attains the expected optimum.
Common Mistake and Practical Implications
A common mistake is to reason that because a zero-probability class contributes zero to the expected loss, it is harmless to require its forecast probability to be positive and then claim the optimum is still attained. The zero contribution explains why the boundary forecast has finite risk; it does not make that forecast a member of the open simplex. For a deterministic outcome, every strictly positive probability assigned elsewhere forces the probability of the certain class below one and makes its log loss strictly positive.
A related notational trap is confusing the entropy convention \(0\log 0=0\) with the realized loss \(-\log 0=+\infty\). Entropy is an expectation-like sum in which a zero-probability term is omitted. Realized log loss is infinite if the observed class was assigned probability zero. These facts are compatible: an event of conditional probability zero contributes nothing to expected risk, although assigning zero probability to an event that can occur produces infinite risk.
In computation, probability clipping or smoothing is often used to avoid infinite numerical losses. It creates forecasts in the open simplex and can be useful operationally, but a fixed smoothing amount generally changes the forecast and leaves positive excess risk. The distinction here is exact: on the closed simplex a boundary optimum is valid; on the open simplex it may only be approximated. The relevant choice is therefore not whether log loss “works” at the boundary, but whether the permitted forecast space includes that boundary.
Check Your Understanding
Use the distinction between the closed and open simplex to answer the following.
- For \(p=(0,1)\), what is the minimum conditional risk on the closed simplex, and why is it not attained on the open simplex?
- For an interior vector \(p\), why does restricting forecasts to the open simplex not change the minimizer?
- Explain why a term with \(p_j=0\) contributes zero to expected log risk even when \(q_j=0\), while \(p_j>0\) and \(q_j=0\) gives infinite risk.
- For \(p=(1,0,0)\), calculate the risk of \(q=(0.9,0.05,0.05)\). Does this forecast attain the infimum over the open simplex?
- If boundary conditional probabilities occur only on a probability-zero set of feature values, must an open-simplex restriction prevent attainment of the expected optimum? Explain.