Tutorials › Statistical Learning (Graduate) › Factorized Losses and Marginal Calibration

Multiclass and Structured Losses · Tutorial 587 of 989

Factorized Losses and Marginal Calibration

Learn when calibrated marginals suffice for structured decisions and when dependence or output constraints require more than coordinatewise surrogate guarantees.

Advanced 11 min read

What You'll Learn

  • Define marginal calibration for binary coordinates of a structured output.
  • Derive why factorized logistic loss recovers each conditional marginal, even under dependence.
  • Prove when marginal probabilities suffice for additive task losses.
  • Distinguish Hamming-optimal decisions from exact-match or joint-MAP predictions.
  • Identify why coordinatewise thresholding may fail when outputs are constrained.

Why Factorization Does Not Mean Independence

A structured label can contain several dependent components: a sequence of tags, a set of attributes, or a vector of binary outcomes. A factorized surrogate assigns a separate loss to each component and adds those losses. This can make its conditional risk straightforward to analyze, but it does not make the components statistically independent. The central question is what information the factorized objective recovers, and whether that information is enough for the task’s decision rule.

We focus on a binary vector \(Y=(Y_1,\ldots,Y_d)\), where \(Y_i\in\{0,1\}\), and condition on a feature value \(X=x\). Write \(\eta_i(x)=P(Y_i=1\mid X=x)\) for the \(i\)th conditional marginal. Dependence among coordinates is encoded by the joint conditional distribution of \(Y\); the collection of marginals \((\eta_1(x),\ldots,\eta_d(x))\) generally does not specify that joint distribution.

Definition: A coordinatewise surrogate is marginally calibrated if, for each coordinate \(i\), minimizing its conditional surrogate risk recovers \(\eta_i(x)=P(Y_i=1\mid X=x)\). A factorized surrogate has conditional risk equal to a sum of coordinatewise risks. Neither definition assumes that the coordinates of \(Y\) are conditionally independent.

Logistic Loss Recovers the Marginals

For predicted probabilities \(r=(r_1,\ldots,r_d)\in[0,1]^d\), the factorized logistic loss is

$$ \ell_{\mathrm{fact}}(r,Y) = \sum_{i=1}^d \left[-Y_i\log r_i-(1-Y_i)\log(1-r_i)\right]. $$

Use the usual extended-value conventions: a term with zero multiplier is zero, while assigning probability zero to an event with positive probability gives infinite loss. The conditional risk is the expectation of this loss given \(X=x\).

Theorem: For any conditional joint distribution of \(Y\) given \(X=x\), the minimizers of the factorized logistic conditional risk satisfy \(r_i=\eta_i(x)\) for every coordinate \(i\). The minimum value is the sum of the binary entropies of the marginals. This statement allows arbitrary dependence among the coordinates.

Proof. By linearity of expectation, the conditional risk is the sum of the coordinatewise conditional risks. For coordinate \(i\), only the marginal probability \(\eta_i=\eta_i(x)\) enters:

$$ \begin{aligned} R_i(r_i\mid x) &=E[-Y_i\log r_i-(1-Y_i)\log(1-r_i)\mid X=x]\\ &=-\eta_i\log r_i-(1-\eta_i)\log(1-r_i). \end{aligned} $$

For \(0<\eta_i<1\), differentiating with respect to \(r_i\in(0,1)\) gives

$$ \frac{\partial R_i}{\partial r_i} =-\frac{\eta_i}{r_i}+\frac{1-\eta_i}{1-r_i} =\frac{r_i-\eta_i}{r_i(1-r_i)}. $$

The denominator is positive, so the derivative is negative for \(r_i<\eta_i\) and positive for \(r_i>\eta_i\). Thus \(r_i=\eta_i\) is the unique minimizer. Substitution gives the minimum \(-\eta_i\log\eta_i-(1-\eta_i)\log(1-\eta_i)\). If \(\eta_i=0\), the risk is minimized at \(r_i=0\); if \(\eta_i=1\), it is minimized at \(r_i=1\), with the same entropy formula interpreted by continuity. Since the total risk is a sum and each term depends only on its own \(r_i\), its minimizers are precisely the coordinatewise minimizers just found. No step uses the joint probabilities of \(Y\), so dependence does not alter the result. \(\square\)

Worked Example: Correlated Labels and the Logistic Optimum

Suppose, conditional on a fixed \(x\), that \(Y=(1,1)\) with probability \(0.3\) and \(Y=(0,0)\) with probability \(0.7\). The coordinates are perfectly dependent. Nevertheless, each marginal is \(\eta_i=0.3\), so the theorem says the factorized logistic optimum is \(r_1=r_2=0.3\).

For either coordinate, the conditional logistic risk at \(r_i=0.3\) is \(-0.3\log(0.3)-0.7\log(0.7)\), approximately \(0.6109\). The total risk is approximately \(1.2217\). At \(r_i=0.5\) for both coordinates, the total risk is \(2\log 2\), approximately \(1.3863\), which is larger. The optimum is determined by the two marginals; it does not require an independence assumption.

When Marginals Are Sufficient for the Task

Marginal calibration is especially useful when the task loss is additive across coordinates. The action need not range over every binary vector: it may be restricted to a feasible set \(A\subseteq\{0,1\}^d\). What matters is that the loss of an action \(a\in A\) on outcome \(y\) can be written as a sum of coordinate losses \(c_i(a_i,y_i)\).

Theorem: Let \(A\subseteq\{0,1\}^d\) be a nonempty finite action set, and suppose the task loss has the form \(L(a,y)=\sum_{i=1}^d c_i(a_i,y_i)\). For any conditional distribution of \(Y\mid X=x\), the conditional task risk of each action \(a\in A\) depends on that distribution only through the marginals \(\eta_1(x),\ldots,\eta_d(x)\). Consequently, any action minimizing that risk can be selected using the marginals and the specified action set.

Proof. Finite additivity of expectation gives

$$ \begin{aligned} E[L(a,Y)\mid X=x] &=\sum_{i=1}^d E[c_i(a_i,Y_i)\mid X=x]\\ &=\sum_{i=1}^d\left[ (1-\eta_i(x))c_i(a_i,0)+\eta_i(x)c_i(a_i,1) \right]. \end{aligned} $$

The expression contains no joint probabilities such as \(P(Y_i=1,Y_j=1\mid X=x)\). Therefore the marginals determine the risk of every action in \(A\). Since \(A\) is finite and nonempty, at least one action attains the minimum of these risks; comparing them yields a Bayes action. This proves the claim, including when \(A\) imposes constraints on the output. \(\square\)

For Hamming loss, \(L(a,y)=\sum_i \mathbf{1}\{a_i\ne y_i\}\), each coordinate’s conditional error is \(\eta_i\) when predicting zero and \(1-\eta_i\) when predicting one. If every binary vector is allowed, minimizing each term separately gives \(a_i=1\) when \(\eta_i>1/2\), \(a_i=0\) when \(\eta_i<1/2\), and either value at a tie. If actions are constrained, the theorem still says marginals suffice for additive Hamming risk, but the decision must minimize total risk over the feasible set. Independent thresholding is not automatically a feasible or optimal procedure.

Worked Example: Hamming Decisions and Joint MAP Differ

Let the conditional joint distribution be \(P(00\mid x)=0.35\), \(P(11\mid x)=0.34\), \(P(01\mid x)=0.31\), and \(P(10\mid x)=0\). Then \(\eta_1=0.34\) and \(\eta_2=0.65\). The coordinatewise Hamming decision is \(01\). Its conditional Hamming risk is \(0.34+0.35=0.69\): the first coordinate is wrong when \(Y_1=1\), and the second is wrong when \(Y_2=0\).

The joint-MAP action, which maximizes the probability of the complete label, is instead \(00\), with probability \(0.35\). Its Hamming risk is \(0.34+0.65=0.99\). Thus the marginal decision is optimal for Hamming loss, while the joint-MAP decision is optimal for exact-match loss. They answer different decision problems.

Moreover, these marginals do not determine the joint-MAP action. For example, the distribution \(P(00\mid x)=0.01\), \(P(10\mid x)=0.34\), \(P(01\mid x)=0.65\), \(P(11\mid x)=0\) has the same marginals, but its joint-MAP action is \(01\). A factorized marginal surrogate alone cannot distinguish these two joint distributions.

Constraints and Coordinatewise Guarantees

The distinction between recovering marginals and making a feasible structured prediction matters whenever the output space has dependencies built into its admissible configurations. A decoder may use calibrated marginal scores to search the feasible set under an additive task loss. But simply applying the unconstrained coordinatewise decision rule can produce an invalid output. The following example shows this even when the conditional labels themselves always satisfy a structural constraint.

Worked Example: Parity Constraints Defeat Independent Thresholding

Suppose the only possible labels are \(110\), \(101\), and \(011\), each with conditional probability \(1/3\). Every label has exactly two ones, so the conditional marginals are all \(2/3\). Thresholding each marginal at \(1/2\) produces \(111\), which is not an allowed label.

Suppose the feasible action set is also \(A=\{110,101,011\}\), and the task loss is Hamming loss. For action \(110\), the expected coordinatewise errors are \(1/3\), \(1/3\), and \(2/3\), for a total risk of \(4/3\). By symmetry, each of the three feasible actions has risk \(4/3\), so any is Bayes-optimal. The marginals are sufficient to compare feasible actions, but thresholding without respecting the constraint does not solve that constrained decision problem.

Coordinatewise guarantees also have a precise scope. If estimated scores approach the true marginals and the target is unconstrained Hamming prediction, then each coordinate whose marginal is strictly on one side of \(1/2\) eventually receives the correct threshold decision. At a marginal of exactly \(1/2\), either decision has the same coordinatewise risk. This is a guarantee about marginal probabilities and additive coordinate risk; it is not a guarantee that a model has learned the full conditional joint distribution.

The same caution applies to the word “factorized.” A product distribution constructed from scores \(r_i\) assigns probability \(\prod_i r_i^{y_i}(1-r_i)^{1-y_i}\) to a vector \(y\). That is a particular joint distribution with independent coordinates. Marginal calibration establishes that its factors match the true marginals; it does not establish that this product is the true joint distribution. If the task loss depends on co-occurrence patterns or on the probability of a whole configuration, joint information may be necessary.

Common Mistakes

  • Assuming factorization asserts independence. The factorized logistic risk is a sum of expectations, so each term uses one marginal. This algebra does not assert that the labels are independent.
  • Treating calibrated marginals as a calibrated joint distribution. Distinct joint distributions can share all coordinate marginals, as in the worked example. A product of marginals is an approximation unless independence is justified.
  • Using a Hamming-optimal decoder for every task. Thresholding marginals minimizes unconstrained Hamming risk, not necessarily exact-match risk or another set-level loss.
  • Thresholding before checking feasibility. With a constrained output set, coordinatewise decisions can be inadmissible. For additive loss, compare the risks of feasible actions instead.
Key takeaway: Factorized proper losses can recover every conditional marginal without modeling dependence. Those marginals suffice for additive coordinatewise task losses, including constrained additive decisions when the decoder optimizes over feasible actions. They do not, by themselves, determine joint probabilities or solve tasks whose risk depends on whole configurations.

Check Your Understanding

Use the distinction between marginal calibration and joint prediction to answer the following.

  1. Why does the conditional risk of factorized logistic loss depend on each coordinate’s marginal but not on pairwise probabilities?
  2. For unconstrained binary-vector prediction under Hamming loss, what decision minimizes risk when a marginal equals \(1/2\)?
  3. Can two conditional joint distributions have the same marginals but different joint-MAP labels? Explain.
  4. When the feasible action set is restricted, what must a decoder do to obtain a Bayes action under additive Hamming loss?
  5. Why does multiplying calibrated marginal probabilities not generally recover the true joint distribution?
Clinical Biostats