betaFeedback

WorksComputer Science

When Is Product Decoding of ECOC MAP-Consistent? Pair Structure and the n-vs-Rest Codes

Abstract

Error-Correcting Output Codes (ECOC) combine binary classifiers by the sum decoder, which totals probabilities, or the product decoder, which totals log-likelihoods. In the noiseless setting, where the binary classifiers output the true posteriors, we ask on which code matrices each decoder always agrees with the Bayes-optimal (MAP) class. For the sum decoder the answer is known: the code must be equidistant (James and Hastie, 1998). We answer the question for the product decoder. Two classes are compared through the votes of the columns on which they differ: the sum decoder decides by their sample mean, the product decoder by an M-estimator with influence function artanh, and each vote is the MAP margin plus a bias determined by the other classes alone. Our main theorem states that the product decoder is MAP-consistent if and only if, for every class pair, the columns on which the two classes differ are matched with the columns obtained by swapping the two classes (or their complements), and equivalently if and only if the code is a union of n-vs-Rest codes. Efficient equidistant codes are therefore excluded: Hadamard codes (M≥8M\ge 8), which meet the Plotkin bound with M−1M-1 columns, have no such pairs, and for the Sylvester type the reversal margin can be at least a constant 0.0182 independent of MM. All theorems are machine-checked in Lean 4. On six real datasets with estimated probabilities, the product decoder is slightly more accurate when each column is calibrated, and the sum decoder is better when the calibration error differs across columns; in either case the decoders disagree only near ties.

Introduction

Error-Correcting Output Codes (ECOC) reduce multi-class classification to binary problems [4, 1]. Each class mm is assigned a code word cm∈{0,1}nc_m \in\{0,1\}^n, and a binary classifier is trained for each column jj; decoding aggregates the outputs pjp_j and predicts the class with the “closest” code word.

Decoders fall into two groups: the sum decoder (L1L_1 decoding [4]), which adds the column probabilities, and the product decoder (loss-based decoding (Allwein et al., 2000; Passerini et al., 2004)), which adds the Bernoulli log-likelihoods of the columns. Which should be used? Our answer:

If the classifiers output the true posteriors, the sum decoder always returns the MAP class if and only if the code is equidistant (James & Hastie, 1998b), and the product decoder if and only if the code is a union of nn-vs-Rest codes. Short codes with large distance, such as Hadamard codes, are equidistant but not of this form, so on them only the sum decoder is safe. For real classifiers with estimation error, the product decoder is slightly more accurate when each column is calibrated individually, and the sum decoder is better when the calibration error varies across columns. In either case the two decoders differ only near ties.

We derive the first part of this answer in the noiseless setting, in which the binary classifiers are perfect:

p=CTπ∈[0,1]n,(1)p = C^{\mathsf{T}}\pi\in[0,1]^n, \tag*{(1)}

where π∈ΔM−1\pi\in\Delta^{M-1} is the true posterior vector. Here any disagreement with MAP is caused by the decoding rule and the code structure, not by estimation error.

The answer matters because codes differ greatly in cost. The number of binary classifiers is the code length, and the error-correcting power is governed by the distance between code words. The nn-vs-Rest codes (nvR: the columns are all splits of nn classes versus the rest) include 1-vs-Rest, which has length MM but distance only 2, and 2vR, whose distance 2(M−2)2(M-2) costs (M2)\binom{M}{2} columns. The Hadamard code reaches distance M/2M/2 with only M−1M-1 columns, meeting the Plotkin bound (Plotkin, 1960), and is used in ECOC practice [2] (Yin et al. 2005; Verma & Swami 2019). Which decoder may be used with such efficient codes?

Contributions

Our analysis rests on one observation. In comparing classes mm and m′m', only the columns on which their code words differ matter, and each casts a vote for mm or m′m'. The sum decoder decides by the sample mean of these votes, the product decoder by an M-estimator through artanh. For every code, each vote is the MAP margin πm−πm′\pi_m-\pi_{m'} plus a bias determined by the background mass alone (§ 3). We obtain the following results.

First, the main theorem: the product decoder is MAP-consistent for all π\boldsymbol{\pi} in the interior of the simplex if and only if every class pair has pair structure, and if and only if the code is a union of nvR codes (Theorem 1). Pair structure means that the columns on which two classes differ are matched one to one with the columns obtained by swapping the two classes (or their complements). Prior work (Kumoi et al., 2021) represented each column by the pair of class sets on its two sides and defined this correspondence as a symmetry condition. It showed that the condition suffices for product consistency and proved consistency for the nvR family. The main theorem strengthens this to a necessary and sufficient condition and identifies the codes that satisfy it: pair structure for every class pair makes the code invariant under every permutation of the classes, and the invariant codes are exactly the unions of nvR codes. For comparison we restate the known condition for the sum decoder, equidistance (James & Hastie, 1998b), in the same terms (Proposition 1): the sum decoder needs only the first moment of the votes to balance, the product decoder the whole vote distribution. Every product-consistent code is therefore sum-consistent (Corollary 3), but not conversely.

Second, Hadamard codes (M≥8M \ge8) do not have a single paired column because their columns are orthogonal (Proposition 3), so for every type of Hadamard matrix the product decoder can disagree with MAP on every class pair. For the Sylvester type, the reversal margin can be at least a constant δ~≈0.018175\tilde{\delta} \approx0.018175 independent of MM (Theorem 2). To leading order the reversal margin is governed by the variance of the vote sample (Eq. (9)), and under typical posterior distributions it roughly decays with MM (Experiment B). The efficiency of the Hadamard code and product consistency are thus incompatible.

Third, experiments on six real datasets examine which decoder is better under estimation error (§ 7). The product decision, a signed sum of log-odds, is invariant to a temperature common to all columns, and with calibrated classifiers the product decoder is slightly more accurate. When the calibration error differs across columns, the sum decoder, which uses bounded votes, is better.

All theorems, lemmas, propositions, and corollaries in Sections 3–6, including the proofs in the appendix, have been machine-checked in Lean 4 with Mathlib (ancillary files of this arXiv submission).

Relation to prior work

Bayes optimality of L1L_1 decoding (James and Hastie). James & Hastie (1998b) (see also James & Hastie (1998a)) showed that L1L_1 decoding, i.e., the sum decoder, is Bayes optimal—it returns the Bayes class whenever the binary classifiers are Bayes classifiers—if and only if the code is equidistant. Proposition 1 restates their theorem for the order of every class pair and in the weak form. We include its short proof because the vote decomposition used there is the starting point for the product decoder.

Robustness to estimation error (Kittler et al.). Kittler et al. (1998) showed that the product rule is Bayes optimal for conditionally independent representations and that the sum rule approximates it when the posteriors are close to the priors, and argued that the sum rule is robust to estimation error. Their question is which combination rule is robust to noisy estimates; ours is whether each decoder, as a function of the code CC, reproduces MAP given the true probabilities. The two are complementary. In our real-data experiments, with calibrated classifiers the product decoder is sometimes the one that is correct when the two decoders disagree (§ 7).

Asymptotic surrogate consistency (Ramaswamy et al.). Ramaswamy et al. (2014) give conditions on the code matrix under which minimizing a binary surrogate loss recovers the Bayes classifier in the infinite-data limit. There the decoder is designed for the code (the inverse link of a proper composite loss followed by a linear decoding), and consistency is decided by a column-space condition on the code matrix. We go the other way: the decoder is fixed to the plain product (or sum) rule, and we characterize the codes on which it is consistent. Our study of a fixed code, noiseless probabilities, and plain decoders is thus complementary.

Symmetry condition for the product decoder (Kumoi et al., 2021). Prior work showed, through a symmetry condition on class pairs, that the product decoder is MAP-consistent for nvR codes (including 1-vs-Rest, 2vR, half-vs-half) and the Exhaustive code. We add (i) the necessity of this symmetry condition (equivalent to pair structure) for the product decoder and the identification of all codes that satisfy it (Theorem 1); (ii) the inclusion between the two decoders (Corollary 3); and (iii) the absence of pair structure in Hadamard codes (M≥8M \ge8), the resulting inconsistency of the product decoder, and the size of its reversal margin (§ 6). The Hadamard code with M=4M = 4 coincides with the 2vR code up to column complements and is the only Hadamard code with pair structure (Remark 1).

Passerini et al. (2004) proposed a probability-based (product-like) decoder but gave no MAP-consistency condition. The loss-based decoding of Allwein et al. [1] has the same form as the product decoder, but their theorems bound the training and generalization errors. Tax et al. (2000) showed that sum and product coincide in the special case of two classes and two classifiers. Viewing sum and product as linear and logarithmic opinion pools (DeGroot & Mortera [3]; Genest & Zidek (1986)) places both among aggregation rules.

Section 2 defines the notation and the decoders, Section 3 decomposes the votes, Section 4 restates the condition for the sum decoder, and Section 5 proves the main theorem for the product decoder. Section 6 treats Hadamard codes, Section 7 presents experiments, Section 8 discusses, and Section 9 concludes. Details are in the appendix.

Preliminaries

Decoders and MAP-consistency

Let C∈{0,1}M×nC \in\{0,1\}^{M \times n} be the code matrix for MM classes and code length nn (row mm is the code word cm\mathbf{c}_m), d(m,m′)d(m,m') the Hamming distance between code words, and wm=∑jcmjw_m = \sum_j c_{mj} the row weight. Given binary-classifier probabilities p∈[0,1]n\mathbf{p} \in[0,1]^n, the two decoding scores of class mm are

Vm=∑j[cmjpj+(1−cmj)(1−pj)],(2)V_m = \sum_j [c_{mj}p_j + (1-c_{mj})(1-p_j)], \tag*{(2)}
Lm=∑j[cmjlog⁡pj+(1−cmj)log⁡(1−pj)].(3)L_m = \sum_j [c_{mj}\log p_j + (1-c_{mj})\log(1-p_j)]. \tag*{(3)}

with predictions m^=arg⁡max⁡mVm\hat{m}=\arg\max_m V_m and m^=arg⁡max⁡mLm\hat{m}=\arg\max_m L_m. The sum decoder is equivalent to L1L_1 decoding onto the code words in {0,1}n\{0,1\}^n [4], and the product decoder sums the Bernoulli log-likelihoods of the columns, i.e., is a logarithmic pool (Genest & Zidek, 1986).

We assume that no column of the code matrix is all-0 or all-1 and that all code words are distinct. Since the product score requires pj∈(0,1)p_j\in(0,1), statements about the product decoder take π\boldsymbol{\pi} in the relative interior of the simplex (all entries positive), where these assumptions give 0<pj<10<p_j<1 for every column. The sum decoder is treated on all of ΔM−1\Delta^{M-1}, including the boundary. Complementing column jj (0↔10\leftrightarrow1) maps pj→1−pjp_j\to1-p_j and leaves the jjth term of VmV_m and LmL_m unchanged: a complemented column is the same classifier for both decoders. We therefore assume that a code contains no repeated column and no pair of mutually complemented columns (repeating every column equally often leaves both decoders unchanged, and repeating only some amounts to weighting columns).

The MAP class is m^MAP=arg⁡max⁡mπm\hat{m}_{\mathrm{MAP}}=\arg\max_m\pi_m. A decoder DD (VV or LL) is MAP-consistent if, for every π\boldsymbol{\pi} in the range considered,

sign⁡(Dm−Dm′)=sign⁡(πm−πm′)(∀m≠m′),(4)\operatorname{sign}(D_m-D_{m'})=\operatorname{sign}(\pi_m-\pi_{m'})\qquad(\forall m\ne m'), \tag*{(4)}

i.e., the preference order of the decoder agrees with the posterior order on every class pair; at a tie πm=πm′\pi_m=\pi_{m'} we require Dm=Dm′D_m=D_{m'}. For the weak form, which imposes only πm>πm′⇒Dm>Dm′\pi_m>\pi_{m'}\Rightarrow D_m>D_{m'}, Proposition 1 and Theorem 1 give the same conditions.

Here noiseless refers to the assumption that the binary classifiers output the true posteriors without error (p=C⊤π\mathbf{p}=C^\top\boldsymbol{\pi}), the same term as in prior work (Kumoi et al., 2023). Real classifiers have p^j≠pj\hat{p}_j\ne p_j, introducing estimation error, which we treat in the real-data experiment of § 7 (Experiment C).

Equidistant codes and the code families studied

Definition 1 (Equidistant code). A code matrix CC is equidistant if every pair of distinct classes has the same Hamming distance d=d(C)d=d(C).

Table 1 lists the code families studied and our conclusions. An nvnvR code has as columns all partitions of nn classes versus the rest, including 1-vs-Rest (n=1n=1), 2vR (n=2n=2; two classes versus the rest, not one-vs-one), and half-vs-half (n=M/2n=M/2). The normalized Hadamard code is the M×(M−1)M\times(M-1) code obtained from a normalized Hadamard matrix of order MM by deleting the constant column and mapping ±1\pm1 to {1,0}\{1,0\}. Class 0 has the all-ones code word, the other classes have weight M/2−1M/2-1, and every class pair is at distance M/2M/2 (Plotkin, 1960). With a Sylvester matrix (MM a power of two), its code words are those of the simplex code with every bit complemented.

Remark 1 (Hadamard code with M=4M=4). The normalized Hadamard code with M=4M=4 has three columns, each placing exactly two classes on one side, so its column set coincides, up to complements, with that of the 2vR code (= half-vs-half (M=4M=4)). For M≥8M\ge8 it coincides with no nvnvR code. As shown in § 6, the presence of pair structure also splits at this boundary between M=4M=4 and M≥8M\ge8.

Class-Pair Comparisons as Samples of Votes

We express the class-pair comparisons of both decoders through one object, the sample of votes cast by the columns on which the two classes differ; the results hold for every code. Fix a class pair (m,m′)(m,m') and write T=Tmm′T=T_{mm'} for the set of columns on which cmc_m and cm′c_{m'} differ, and s=∣T∣=d(m,m′)s=|T|=d(m,m'). Outside TT we have cmj=cm′jc_{mj}=c_{m'j}, so only the columns in TT contribute to Vm−Vm′V_m-V_{m'} and Lm−Lm′L_m-L_{m'}.

Definition 2 (Support, vote, agreement sign). For a column j∈Tj\in T, the total posterior of the classes with the same bit as class mm, qj:=∑k:ckj=cmjπkq_j:=\sum_{k:c_{kj}=c_{mj}}\pi_k, is the support for mm in column jj, and zj:=2qj−1∈[−1,1]z_j:=2q_j-1\in[-1,1] is the vote of column $j. The vote is positive if it leans toward mm and negative if toward m′m'. For a background class k∉{m,m′}k\notin\{m,m'\}, the agreement sign is τkj:=+1\tau_{kj}:=+1 if ckj=cmjc_{kj}=c_{mj} and −1-1 otherwise, and τj:=(τkj)k∉{m,m′}∈{±1}M−2\tau_j:=(\tau_{kj})_{k\notin\{m,m'\}}\in\{\pm1\}^{M-2} is the agreement pattern of column $j.

If cmj=1c_{mj}=1 then qj=pjq_j=p_j, and if cmj=0c_{mj}=0 then qj=1−pjq_j=1-p_j. Using the odd symmetry ℓ(1−p)=−ℓ(p)\ell(1-p)=-\ell(p) of the log-odds ℓ(p)=log⁡p1−p=2artanh⁡(2p−1)\ell(p)=\log\frac{p}{1-p}=2\operatorname{artanh}(2p-1), we obtain

Vm−Vm′=∑j∈Tzj,Lm−Lm′=∑j∈Tℓ(qj)=2∑j∈Tartanh⁡(zj).(5)V_m-V_{m'}=\sum_{j\in T}z_j,\qquad L_m-L_{m'}=\sum_{j\in T}\ell(q_j)=2\sum_{j\in T}\operatorname{artanh}(z_j). \tag*{(5)}

That is, the sum decoder decides a class pair by the sign of the sample mean of the votes, and the product decoder by the sign of the sum of the votes passed through artanh⁡\operatorname{artanh}. Since artanh⁡\operatorname{artanh} is strictly increasing, the latter is equivalent to taking the sign of the root μ\mu of the location M-estimating equation ∑jartanh⁡(zj−μ)=0\sum_j\operatorname{artanh}(z_j-\mu)=0 with influence function artanh⁡\operatorname{artanh}. The slope of artanh⁡\operatorname{artanh} diverges as zj→±1z_j\to\pm1, so the product decoder weights confident columns (votes near ±1\pm1) heavily, the opposite of a Huber-type M-estimator, which suppresses outliers.

Lemma 1 (Vote decomposition). Let β:=πm−πm′\beta:=\pi_m-\pi_{m'}. For every j∈Tj\in T,

zj=β+aj,aj:=∑k∉{m,m′}πkτkj.(6)z_j=\beta+a_j,\qquad a_j:=\sum_{k\notin\{m,m'\}}\pi_k\tau_{kj}. \tag*{(6)}

The bias aja_j is determined by the background posteriors b:=(πk)k∉{m,m′}\mathbf{b}:=(\pi_k)_{k\notin\{m,m'\}} alone and does not involve πm,πm′\pi_m,\pi_{m'}.

Proof. For j∈Tj\in T we have cmj≠cm′jc_{mj}\ne c_{m'j}, so class mm belongs to qjq_j and class m′m' to 1−qj1-q_j. Hence zj=qj−(1−qj)=πm−πm′+∑k∉{m,m′}πkτkjz_j=q_j-(1-q_j)=\pi_m-\pi_{m'}+\sum_{k\notin\{m,m'\}}\pi_k\tau_{kj}.

By Lemma 1, fixing the background mass b\mathbf{b} and moving mass only between mm and m′m' translates the vote sample {zj}j∈T\{z_j\}_{j\in T} by β\beta without changing its shape. We work on this one-dimensional family. Since πm+πm′=1−∑kbk=:r\pi_m+\pi_{m'}=1-\sum_k b_k=:r, β\beta ranges over [−r,r][-r,r] on it ((−r,r)(-r,r) for the product decoder). Figure 1 gives an example: with pair structure (§ 5) the sample is symmetric and the two decoders agree; without it, artanh⁡\operatorname{artanh} stretches the large votes of a skewed sample and only the product decoder can reverse the MAP order.

Figure 1. Vote sample of one class pair, with the same masses in both panels (πm=0.195\pi_m = 0.195, πm′=0.205\pi_{m'} = 0.205, 0.2 on each of three background classes; MAP picks m′m'). The sum decoder decides by the sign of the mean of the votes zjz_j, the product decoder by the sign of the mean of artanh⁡zj\operatorname{artanh} z_j. (a) With pair structure the sample is symmetric and the two decoders agree. (b) For the Hadamard code with M=8M = 8 the sample is skewed; artanh stretches the large vote, and only the product decoder reverses. The masses in (b) are the construction of Theorem 2, with class indices translated in F24\mathbb{F}_2^4.

The sum of the biases is expressed by code distances.

Lemma 2 (Distance identity). For every background class k∉{m,m′}k\notin\{m,m'\}, ∑j∈Tτkj=d(k,m′)−d(k,m)\sum_{j\in T}\tau_{kj}=d(k,m')-d(k,m). Hence

Vm−Vm′=d(m,m′)(πm−πm′)+∑k∉{m,m′}πk[d(k,m′)−d(k,m)].(7)V_m-V_{m'}=d(m,m')(\pi_m-\pi_{m'})+\sum_{k\notin\{m,m'\}}\pi_k[d(k,m')-d(k,m)]. \tag*{(7)}

Proof. For j∈Tj\in T, the bit of kk agrees with exactly one of mm and m′m'. Thus ∑j∈Tτkj\sum_{j\in T}\tau_{kj} is the number of columns in TT on which kk agrees with mm minus the number on which it agrees with m′m', i.e., dT(k,m′)−dT(k,m)d_T(k,m')-d_T(k,m) for the distance dTd_T restricted to TT. Outside TT, cmc_m and cm′c_{m'} agree, so the contributions outside TT are equal in both distances and the difference is d(k,m′)−d(k,m)d(k,m')-d(k,m). Eq. (7) follows by substituting into Eqs. (5) and (6).

The second term of Eq. (7) says that each background class kk pulls the sum decision toward the class closer to itself: if kk is closer to mm (d(k,m)<d(k,m′)d(k,m)<d(k,m')), the decision shifts toward mm.

Sum Decoder: Equidistance Is Necessary and Sufficient

The condition for the sum decoder is known (James & Hastie, 1998b). We restate it in the language of votes, which sets up the comparison with the product decoder.

Proposition 1 (Sum decoder; James & Hastie, 1998b). Let M≥3M \ge3. The sum decoder is MAP-consistent for all π∈ΔM−1\pi\in\Delta^{M-1} if and only if the code is equidistant, in which case Vm−Vm′=d(C)(πm−πm′)V_m - V_{m'} = d(C)(\pi_m - \pi_{m'}). The equivalence also holds for the weak form of consistency that does not require ties.

Proof. (Sufficiency) If the code is equidistant, the second term of Eq. (7) vanishes and Vm−Vm′=d(C)(πm−πm′)V_m - V_{m'} = d(C)(\pi_m - \pi_{m'}). Since d(C)≥1d(C) \ge1, the signs agree.

(Necessity) Take distinct k,m,m′k,m,m', and for t∈(0,1)t \in(0,1) and ε\varepsilon with ∣ε∣<(1−t)/2|\varepsilon| < (1-t)/2 set πm=(1−t)/2+ε\pi_m = (1-t)/2 + \varepsilon, πm′=(1−t)/2−ε\pi_{m'} = (1-t)/2 - \varepsilon, πk=t\pi_k = t, and all others 0. By Eq. (7), Vm−Vm′=2εd(m,m′)+t[d(k,m′)−d(k,m)]V_m - V_{m'} = 2\varepsilon d(m,m') + t[d(k,m') - d(k,m)]. Even under weak consistency this must be positive for ε>0\varepsilon> 0 and negative for ε<0\varepsilon< 0, so letting ε→0\varepsilon\to0 gives t[d(k,m′)−d(k,m)]=0t[d(k,m') - d(k,m)] = 0, i.e., d(k,m)=d(k,m′)d(k,m) = d(k,m'). Since this holds for any three distinct classes, two class pairs sharing a class have equal distances. Any two class pairs {a,b}\{a,b\}, {c,e}\{c,e\} are connected by a chain of pairs each sharing a class with the next, such as {a,b}→{b,c}→{c,e}\{a,b\} \to\{b,c\} \to\{c,e\} (a shorter chain suffices when, e.g., b=cb = c), so all class pairs have equal distances.

For M=2M = 2, V1−V2=d(1,2)(π1−π2)V_1 - V_2 = d(1,2)(\pi_1 - \pi_2) for distinct code words, so the sum decoder is always MAP-consistent.

Equidistance can also be written as a Gram-matrix condition.

Corollary 1 (Gram-matrix form). A code is equidistant if and only if there exist λ>0\lambda> 0 and ω∈RM\boldsymbol{\omega} \in\mathbb{R}^M such that G=CC⊤=λI+ω1⊤+1ω⊤G = CC^\top= \lambda I + \boldsymbol{\omega}\mathbf{1}^\top+ \mathbf{1}\boldsymbol{\omega}^\top, in which case d(C)=2λd(C) = 2\lambda. In the equal-weight case (ωm\omega_m constant), ω\boldsymbol{\omega} is a constant vector and the condition reduces to G=λI+ω11⊤G = \lambda I + \omega\mathbf{1}\mathbf{1}^\top.

Proof. (⇐\Leftarrow) d(m,m′)=Gmm+Gm′m′−2Gmm′=2λd(m,m') = G_{mm} + G_{m'm'} - 2G_{mm'} = 2\lambda. (⇒\Rightarrow) Setting λ:=d/2\lambda:= d/2 and ωm:=ωm/2−d/4\omega_m := \omega_m/2 - d/4 gives Gmm=ωm=λ+2ωmG_{mm} = \omega_m = \lambda+ 2\omega_m and Gmm′=(ωm+ωm′−d)/2=ωm+ωm′G_{mm'} = (\omega_m + \omega_{m'} - d)/2 = \omega_m + \omega_{m'}.

Application to code families

All code families in Table 1 except logM are equidistant. The Hadamard code has unequal row weights (the all-ones row M−1M-1, the others M/2−1M/2-1) but is equidistant, so the sum decoder is MAP-consistent. logM violates equidistance, and the sum decoder indeed disagrees with MAP (§ 7).

NameShapeEquidistantPair structureSumProduct
1-vs-Rest(M,M)(M,M)Yes, d=2d=2YesYesYes
2vR(M,(M2))(M,\binom{M}{2})Yes, d=2(M−2)d=2(M-2)YesYesYes
Half-vs-Half(M,(M/22))(M,\binom{M/2}{2})Yes, d=M−2M/2−1d=\frac{M-2}{M/2-1}YesYesYes
Hadamard (M=4M=4)(4,3)(4,3)Yes, d=2d=2YesYesYes
Hadamard (M≥8M\ge8)(M,M−1)(M,M-1)Yes, d=M/2d=M/2NoYesNo
logM(M,⌈log⁡2M⌉)(M,\lceil\log_2 M\rceil)NoNoNoNo

Table 1. Code families studied and their MAP-consistency (noiseless setting). Sum/Product: whether the sum/product decoder is MAP-consistent.

The order of a Hadamard matrix is a multiple of four (apart from 1, 2), but equidistance is preserved under row deletion, since deleting rows but keeping columns preserves the distances among the remaining rows.

Corollary 2 (Equidistant codes by row deletion). Deleting two rows from the Hadamard code with M=12M=12 yields an equidistant code with M=10M=10. Deleting two rows including the all-ones row (weight M−1M-1) leaves ten rows forming an equal-weight equidistant code; keeping the all-ones row and deleting two other rows gives an unequal-weight equidistant code. In both cases the sum decoder is MAP-consistent.

Numerically, no noiseless sum-decoder disagreement was observed for either deletion (Appendix § 13). In general, for MM not a multiple of four, deleting rows from the Hadamard code of order M′=4⌈M/4⌉M'=4\lceil M/4\rceil (as done in practice, e.g., by (Verma & Swami, 2019)) gives an equidistant code for MM classes with M′−1≤M+2M'-1\le M+2 columns and distance M′/2≥M/2M'/2\ge M/2: the cost of the missing orders is at most three extra columns.

Remark 2 (Sum ≡\equiv product ≡\equiv bitwise thresholding on complete codes). When MM is a power of two, the logM code has every word of {0,1}log⁡2M\{0,1\}^{\log_2 M} as a code word (a complete code). Each column term can then be maximized independently, so the sum decoder, the product decoder, and bitwise thresholding coincide identically and the two decoders never differ, while their disagreement with MAP equals the gap between the bitwise marginal MAP and the joint MAP. The disagreement of logM is thus not a matter of sum versus product but a structural consequence of cutting the code length to log⁡2M\log_2 M.

Product Decoder: The Main Theorem

The sum decoder looks only at the mean of the votes; through artanh, the product decoder also sees the shape of the vote sample. We characterize product reversals on the one-dimensional family with fixed background (Proposition 2) and then give the necessary and sufficient condition over all π\boldsymbol{\pi} (Theorem 1). Throughout this section π\boldsymbol{\pi} lies in the relative interior of the simplex.

Reversal on a single class pair

Fix a class pair (m,m′)(m,m') and a background b\mathbf{b} (all entries positive, r=1−∑kbk>0r=1-\sum_k b_k>0), and let

Ψb(β):=∑j∈Tartanh⁡(β+aj),(8)\Psi_{\mathbf{b}}(\beta):=\sum_{j\in T}\operatorname{artanh}(\beta+a_j), \tag*{(8)}

where aja_j is the bias of Lemma 1. By Eqs. (5) and (6), Lm−Lm′=2Ψb(β)L_m-L_{m'}=2\Psi_{\mathbf{b}}(\beta) on the family.

Proposition 2 (Reversal on a single class pair). Ψb\Psi_{\mathbf{b}} is strictly increasing on β∈(−r,r)\beta\in(-r,r).

  1. If Ψb(0)=0\Psi_{\mathbf{b}}(0)=0, then sign⁡(Lm−Lm′)=sign⁡β\operatorname{sign}(L_m-L_{m'})=\operatorname{sign}\beta for every β\beta on the family (no reversal occurs).

  1. If Ψb(0)>0\Psi_{\mathbf{b}}(0)>0, then Ψb\Psi_{\mathbf{b}} has a unique root β∗<0\beta^*<0, and the product decoder reverses the MAP order if and only if β∈(max⁡(β∗,−r),0)\beta\in(\max(\beta^*,-r),0). This interval is nonempty. The case Ψb(0)<0\Psi_{\mathbf{b}}(0)<0 follows by swapping m↔m′m\leftrightarrow m'.

Proposition 2 (proved in Appendix § 11) shows that reversal on a class pair is determined solely by whether the bias sample {aj}\{a_j\} is balanced at zero in the artanh sense (whether ∑jartanh⁡(aj)=0\sum_j\operatorname{artanh}(a_j)=0). Even biases with mean zero (as for every equidistant code) need not be balanced, since artanh is nonlinear.

Pair structure and the main theorem

Definition 3 (Pair structure). For a class pair (m,m′)(m,m'), columns j,j′∈Tj,j'\in T are paired if column j′j' equals the column obtained from column jj by swapping its mmth and m′m'th entries, or the complement of that column. The code has pair structure for (m,m′)(m,m') if TT can be partitioned exactly into paired columns.

@

Complements are allowed because a complemented column represents the same classifier (§ 2). The symmetry condition of prior work (Kumoi et al., 2021) is defined on the family of class sets on both sides of each column, so it does not distinguish complements either; since for M≥3M \ge3 the swap has no fixed point on TT, pair structure for all class pairs is equivalent to that condition.

Lemma 3 (Pairs and agreement patterns). Let M≥3M \ge3. Columns j,j′∈Tj,j' \in T are paired if and only if τj′=−τj\tau_{j'}=-\tau_j. Hence the class pair (m,m′)(m,m') has pair structure if and only if the multiset of agreement patterns {τj}j∈T\{\tau_j\}_{j\in T} is invariant under the sign flip τ↦−τ\tau\mapsto-\tau.

Proof. In the ±1\pm1 representation hkj:=2ckj−1h_{kj}:=2c_{kj}-1, we have τkj=hm′jhkj\tau_{kj}=h_{m'j}h_{kj} and hm′j=−hmjh_{m'j}=-h_{mj} (j∈Tj\in T). The swapped column of column jj has entry −hmj-h_{mj} at mm, hmjh_{mj} at m′m', and background entries hkjh_{kj}, so its agreement pattern is (−hmj)hkj=−τkj(-h_{mj})h_{kj}=-\tau_{kj}. Complementing all entries flips the signs of both hmj′h_{mj'} and hkj′h_{kj'}, leaving the agreement pattern unchanged. Hence paired columns satisfy τj′=−τj\tau_{j'}=-\tau_j. Conversely, suppose τj′=−τj\tau_{j'}=-\tau_j. If hmj′=−hmjh_{mj'}=-h_{mj}, the background entries are hkj′=hkjh_{kj'}=h_{kj} and column j′j' equals the swapped column. If hmj′=hmjh_{mj'}=h_{mj}, then hkj′=−hkjh_{kj'}=-h_{kj} and column j′j' equals the complement of the swapped column. For the second statement, τj≠−τj\tau_j\ne-\tau_j when M≥3M\ge3, so if the multiset is invariant under sign flip, each occurrence of a pattern vv can be matched one to one with an occurrence of −v-v, and conversely.

We read each column jj as the split {Aj,Ajc}\{A_j,A_j^c\} of the classes, where Aj={k:ckj=1}A_j=\{k:c_{kj}=1\}.

Definition 4 (Union of nvR codes). A code is a union of nvR codes if its columns, read as splits, are exactly the splits of the nvR codes for nn in some nonempty set N⊆{1,…,⌊M/2⌋}N\subseteq\{1,\ldots,\lfloor M/2\rfloor\}; equivalently, together with every column, every split with the same side sizes is a column.

Examples are each nvR code (N={n}N=\{n\}), the Exhaustive code (N={1,…,⌊M/2⌋}N=\{1,\ldots,\lfloor M/2\rfloor\}), and 1-vs-Rest together with 2vR (N={1,2}N=\{1,2\}).

Theorem 1 (Product decoder; main theorem). Let M≥3M\ge3, take π\pi in the relative interior of the simplex, and let the code satisfy the conventions of § 2 (distinct code words, no repeated or complemented columns). The following are equivalent: (1) the product decoder is MAP-consistent; (2) the product decoder is MAP-consistent in the weak form (πm>πm′⇒Lm>Lm′\pi_m>\pi_{m'}\Rightarrow L_m>L_{m'}); (3) every class pair has pair structure; (4) the code is a union of nvR codes.

Proof. (3)⇒\Rightarrow(1): By Lemma 3, paired j,j′j,j' satisfy aj′=⟨b,τj′⟩=−aja_{j'}=\langle b,\tau_{j'}\rangle=-a_j. Hence Ψb(0)=∑j∈Tartanh⁡(aj)=0\Psi_b(0)=\sum_{j\in T}\operatorname{artanh}(a_j)=0 for every background bb, and by Proposition 2(1) the signs agree for all pairs and all π\pi. (1)⇒\Rightarrow(2): Immediate.

(2)⇒\Rightarrow(3): We prove the contrapositive. If a class pair (m,m′)(m,m') lacks pair structure, it suffices to show Ψb(0)≠0\Psi_b(0)\ne0 for some background bb; then by Proposition 2(2) the product decoder strictly reverses the MAP order on a nonempty interval of β\beta, contradicting weak consistency. In outline: Expanding Ψb(0)=∑j∈Tartanh⁡⟨b,τj⟩\Psi_b(0)=\sum_{j\in T}\operatorname{artanh}\langle b,\tau_j\rangle as a power series in bb, the term of degree kk is 1k∑j∈T⟨b,τj⟩k\frac{1}{k}\sum_{j\in T}\langle b,\tau_j\rangle^k (for kk odd). If Ψb(0)\Psi_b(0) vanished for every background, all these terms vanish, and all odd moments of the distribution of agreement patterns are 0. For a distribution on a finite set, the vanishing of all odd moments is equivalent to symmetry under sign flip, which means pair structure (Lemma 3). Appendix B makes this rigorous by restricting bb to a single ray b=tvb=tv, which needs only a one-variable power series and a Vandermonde matrix.

(3)⇔\Leftrightarrow(4): A column with cmj=cm′jc_{mj}=c_{m'j} is unchanged by swapping mm and m′m'. Hence pair structure for (m,m′)(m,m') says exactly that the set of columns, read as splits, is invariant under the transposition of mm and m′m'. Pair structure for every class pair is thus invariance under every transposition and, since transpositions generate the symmetric group, under every permutation of the classes. The orbit of a split {A,Ac}\{A,A^c\} under all permutations consists of all splits with the same side sizes, i.e., the columns of the nvR code with n=min⁡(∣A∣,M−∣A∣)n=\min(|A|,M-|A|). A set of splits invariant under all permutations is therefore a union of such orbits, which is (4); conversely, a union of nvR codes is invariant under every permutation.

Without the convention on repeated columns, (4) reads: the multiplicity of a split among the columns depends only on its side sizes.

Corollary 3 (Product consistency ⇒\Rightarrow sum consistency). A code on which the product decoder is MAP-consistent is equidistant, and hence the sum decoder is also MAP-consistent. The converse fails (Hadamard codes, M≥8M \ge8; § 6).

Proof. Under pair structure, the pairs τj′=−τj\boldsymbol{\tau}_{j'}=-\boldsymbol{\tau}_j cancel in the sum, so ∑j∈Tτkj=0\sum_{j\in T}\tau_{kj}=0 for every background class kk. By Lemma 2, d(k,m)=d(k,m′)d(k,m)=d(k,m'), and the argument in the necessity part of Proposition 1 shows that the code is equidistant.

Proposition 1 and Theorem 1 are requirements of different strength on the vote biases {aj}\{a_j\}. The sum decoder requires that the sum of the agreement signs of each background class vanish (balance of the first moment); this is equidistance. The product decoder requires that the distribution of agreement patterns itself be symmetric under sign flip (balance of all odd moments); this is pair structure. First-order balance alone is not enough for the product decoder, and through condition (4) the symmetry of the vote distribution for every class pair becomes a symmetry of the whole code under all permutations of the classes.

Application to code families

Corollary 4 (Code families with pair structure). The nvnvR codes (including 1-vs-Rest, 2vR, and half-vs-half), the Exhaustive code, their unions, and the Hadamard code with M=4M=4 have pair structure for every class pair, so both decoders are MAP-consistent on them.

Proof. Each is a union of nvnvR codes: the Exhaustive code is the union over all nn, and the columns of the Hadamard code with M=4M=4 are the three splits of the four classes into two pairs, i.e., half-vs-half with M=4M=4 (Remark 1). Condition (4) of Theorem 1 applies. For pairs of the Hadamard code with M=4M=4 containing class 0 (the all-ones row), both columns of TT lie on the side of class 0, so the pair is given not by the swap but by the complement of the swap.

As in the last case, some columns pair only with the complement of the swapped column when read as 0/1 vectors; representing each column by the class sets on its two sides removes the distinction (the Hadamard code with M=4M=4 is the same matrix as the 2vR example (M=4M=4) of prior work).

Pair structure is fragile. Deleting one column from 2vR breaks its pair, and pair structure is lost for the class pairs that differ on that column. This is consistent with the jump in the product disagreement rate (from 0% to a few %) observed in Experiment A. Row deletion, on the other hand, preserves pair structure (the swap and complement relations still hold on the remaining rows).

Remark 3 (The cost of product consistency). By condition (4), a product-consistent code contains an entire nvnvR block. For M≥8M\ge8, every product-consistent code other than 1-vs-Rest therefore has at least (M2)\binom{M}{2} columns ((Mn)≥(M2)\binom{M}{n}\ge\binom{M}{2} for 2≤n≤M−22\le n\le M-2, and (MM/2)/2≥(M2)\binom{M}{M/2}/2\ge\binom{M}{2} for M≥8M\ge8), while 1-vs-Rest has distance only 2. The Hadamard code reaches distance M/2M/2 with M−1M-1 columns, fewer than 2vR by a factor of about M/2M/2, but has no pair structure (§ 6).

Hadamard Codes: Absence of Pair Structure and the Reversal Margin

Hadamard codes are equidistant, so the sum decoder is consistent. For the product decoder we show that for M≥8M\ge8 no column has a paired column, and we evaluate how large the resulting disagreement can be.

Absence of pair structure

Proposition 3 (Hadamard codes have no pair structure). For every normalized Hadamard code with M≥8M\ge8 (not only the Sylvester type) and every class pair (m,m′)(m,m'), no column in TT has a paired column.

Proof. In the ±1\pm1 representation, suppose columns j,j′∈Tj,j'\in T are paired. The swapped column differs from column jj only in entries mm and m′m', so the entrywise product h⋅j∘h⋅j′h_{\cdot j}\circ h_{\cdot j'} has exactly 2 entries equal to $-1, and for the complement of the swapped column exactly M−2M-2. On the other hand, distinct columns of a Hadamard matrix are orthogonal, so the entrywise product sums to 00, i.e., has exactly M/2M/2 entries equal to −1-1. We have M/2∈{2,M−2}M/2 \in\{2,M-2\} only for M=4M=4.

Corollary 5 (Product inconsistency on Hadamard codes). For every normalized Hadamard code with M≥8M \ge8, the sum decoder is MAP-consistent but the product decoder is not. Moreover, for every class pair there exists π\pi on which the product decoder reverses the MAP order.

Proof. By Proposition 3 no class pair has pair structure, so by the proof of (2)⇒\Rightarrow(3) in Theorem 1, for every class pair there exists π\pi at which a reversal occurs.

The columns of a Hadamard code are maximally spread: any two differ on half of the rows. This enlarges the code distance and gives equidistance (first-order balance), but makes it impossible for two columns to be related by a swap (pair structure). The property that makes the Hadamard code a good error-correcting code thus rules out pair structure. Orthogonality is also why Verma & Swami (2019) choose Hadamard codes, since orthogonal code words make their probability estimates admissible; for MAP-consistency of the product decoder, the orthogonality of the columns is instead the obstacle.

For the Sylvester type, some class does not appear at all in the comparison statistic.

Proposition 4 (Invisible class). For the Sylvester Hadamard code with M=2tM=2^t, index the classes by F2t\mathbb{F}_2^t. For every class pair (m,m′)(m,m'), the class k∗=m⊕m′k^*=m\oplus m' satisfies ck∗j=0c_{k^*j}=0 identically on TT. Hence pjp_j on TT does not involve πk∗\pi_{k^*}, and Lm−Lm′L_m-L_{m'} does not depend on πk∗\pi_{k^*}.

Proof. The code word of class a∈F2ta\in\mathbb{F}_2^t on the nonzero columns j∈F2t∖{0}j\in\mathbb{F}_2^t\setminus\{0\} is caj=(1+χa(j))/2c_{aj}=(1+\chi_a(j))/2 with χa(j)=(−1)⟨a,j⟩\chi_a(j)=(-1)^{\langle a,j\rangle} (since χ0≡1\chi_0\equiv1, c0=1c_0=1). By the character product rule χmχm′=χm⊕m′\chi_m\chi_{m'}=\chi_{m\oplus m'}, T={j:χm(j)χm′(j)=−1}={j:χm⊕m′(j)=−1}T=\{j:\chi_m(j)\chi_{m'}(j)=-1\}=\{j:\chi_{m\oplus m'}(j)=-1\}, so ck∗j=0c_{k^*j}=0 for j∈Tj\in T.

For a pair (0,m)(0,m) containing class 00, k∗=mk^*=m: L0−LmL_0-L_m does not involve πm\pi_m of the compared class itself, whereas the sum decoder gives V0−Vm=M2(π0−πm)V_0-V_m=\frac{M}{2}(\pi_0-\pi_m), which involves πm\pi_m explicitly.

How large can the reversal margin be?

By Proposition 2, the width of the range of β\beta with reversal (the reversal margin) is the root ∣β∗∣|\beta^*| of Ψb\Psi_b (unless it exceeds the feasible range rr). For equidistant codes the biases have mean ⟨a⟩:=1s∑j∈Taj=0\langle a\rangle:= \frac{1}{s}\sum_{j\in T}a_j=0 (Lemma 2). Substituting artanh⁡(y)=y+y3/3+y5/5+⋯\operatorname{artanh}(y)=y+y^3/3+y^5/5+\cdots into Ψb(β∗)=0\Psi_b(\beta^*)=0 and solving for β∗\beta^* with ⟨⋅⟩=1s∑j∈T\langle\cdot\rangle=\frac{1}{s}\sum_{j\in T}, the leading terms are

β∗≈−13⟨a3⟩+15⟨a5⟩+⋯1+⟨a2⟩+⋯.(9)\beta^* \approx-\frac{\frac{1}{3}\langle a^3\rangle+\frac{1}{5}\langle a^5\rangle+\cdots}{1+\langle a^2\rangle+\cdots}. \tag*{(9)}

The numerator has only odd moments (skewness) of the bias sample; the even moments (variance) enter the denominator and suppress the margin. A symmetric bias sample thus produces no reversal (pair structure), and a larger reversal margin requires a skewed sample.

One may expect the background to be diluted and the margin to shrink to 00 as MM grows; under typical posteriors this indeed happens (see below). For the Sylvester type, however, concentrating the background mass on a few classes to maximize skewness keeps the margin at a constant independent of MM.

Theorem 2 (Dimension-independent lower bound on the worst-case reversal margin). Let δˉ\bar{\delta} be the unique positive root of

3artanh⁡(0.2+δ)=artanh⁡(0.6−δ)(10)3\operatorname{artanh}(0.2+\delta)=\operatorname{artanh}(0.6-\delta) \tag*{(10)}

(δˉ≈0.018175\bar{\delta}\approx0.018175). For every Sylvester Hadamard code (M=2t≥8M=2^t\ge8), every class m≠0m\ne0, and every ϵ∈(0,δˉ)\epsilon\in(0,\bar{\delta}), there exists π\pi (in the relative interior) with πm−π0=ϵ\pi_m-\pi_0=\epsilon such that class mm is the MAP class (the largest entry of π\pi) but the product decoder ranks class 00 above mm. That is, the worst-case reversal margin is at least δˉ\bar{\delta}, and δˉ\bar{\delta} does not depend on MM.

The key to the proof is to place mass 1/51/5 on each element of an F2\mathbb{F}_2-closed triple {b1,b2,b1⊕b2}\{b_1, b_2, b_1 \oplus b_2\} of background classes. By the character product rule, the bias aja_j then degenerates to two points, +0.6+0.6 (proportion 1/41/4) and −0.2-0.2 (proportion 3/43/4), and the root equation of Ψ\Psi becomes Eq. (10), which involves neither ss nor MM. The full proof is given in Appendix § 11.

Numerically, ∣β∗∣=0.018175|\beta^*| = 0.018175 agrees to machine precision for M∈{8,16,32,64}M \in\{8, 16, 32, 64\}, and the same construction gives not only a class-pair reversal but also an argmax disagreement. The argmax disagreement persists while the MAP margin (the gap between the top two posteriors) is at most 0.911 δˉ≈0.01660.911\,\bar{\delta} \approx0.0166, independently of MM; the product decoder then picks a class of the background triple. Below, the reversal margin δ∗\delta^* measured in experiments is this MAP margin at points where the argmax disagrees.

δˉ\bar{\delta} is a proven lower bound, not the worst-case supremum. We ran multi-start SLSQP from class pairs whose code words have equal weight and from sampled disagreement points. For every M∈{8,12,16,20,28,32,48,64}M \in\{8, 12, 16, 20, 28, 32, 48, 64\} it found margins δworst∗∈[0.017,0.025]\delta^*_{\mathrm{worst}} \in[0.017, 0.025] (mean 0.0232, coefficient of variation 0.10), each verified with the decoders. These exceed the construction value 0.0166 for every MM. The worst MAP margin with argmax disagreement is thus at least 0.0166 for the Sylvester type, and local search found none above 0.025; its exact value is open. For non-Sylvester types the triple character identity is unavailable, so we have no proved lower-bound constant (numerically, a similar Θ(10−2)\Theta(10^{-2}) is observed).

The typical margin decays with MM

The largest δ∗\delta^* among disagreement points found by random sampling (the typical value below) roughly decays with MM (Dirichlet: 0.0135 at M=8M = 8, 0.0066 at M=16M = 16, about 0.003 at M=48,64M = 48, 64). The product δ∗×M\delta^* \times M ranges over 0.10–0.18 rather than being constant, so a pure 1/M1/M law does not hold. The decay is consistent with Eq. (9): as MM grows, the background mass spreads over many classes and the skewness ⟨a3⟩\langle a^3 \rangle of the bias sample shrinks. The worst-case construction lies in a corner of the simplex with mass on only five classes, which random sampling rarely hits.

Hence, the worst-case reversal margin does not vanish as MM grows, but the π\pi at which reversals occur are confined to a thin region near ties, which shrinks with MM under typical distributions.

Experiments

We examine three questions: A, do the theorems hold numerically (noiseless setting)? B, how large are the reversals on Hadamard codes? C, which decoder is more accurate with real classifiers? A and B confirm the theory; C answers the second half of the question in the introduction (which decoder is better under estimation error). Settings are detailed in Appendix § 13.

A: Numerical confirmation of the theorems

We sampled noiseless probabilities p=CTπ\boldsymbol{p} = C^{\mathsf{T}}\boldsymbol{\pi} (four series per code and MM: Dirichlet α∈{0.3,1.0}\alpha\in\{0.3, 1.0\} and two posteriors built from Gaussian data, 200,000 samples each, or 100,000 for codes with many columns) and measured each decoder’s disagreement rate with MAP (Figure 2). The sum decoder never disagreed on the equidistant codes (all but logM). The product decoder never disagreed on 1-vs-Rest, 2vR, and half-vs-half, which have pair structure, or on the Hadamard code with M=4M = 4; on Hadamard codes with M≥8M \ge8 its rate was small but nonzero (0.145%, 0.265%, and 0.300% for $M = 8, 16, 32). logM disagrees heavily for both decoders (14.0% to 68.6% for M=4M = 4 to 32).

Figure 2. Disagreement rate with MAP in the noiseless setting (%, mean over four series). Left: sum; right: product. The sum decoder is 0 on all equidistant codes (all but logM), the product decoder only on codes with pair structure (1-vs-Rest, 2vR, half-vs-half, Hadamard with M=4M = 4) (Proposition 1 and Theorem 1). n/c: not computed. Half-vs-half has (MM/2)/2\binom{M}{M/2}/2 columns (6435 at M=16M = 16, about 3×1083 \times10^{8} at M=32M = 32), so only M≤8M \le8 was computed; having pair structure, its rate is 0 by the theorem.

The experiments also show that pair structure is fragile (§ 5). Deleting one random column from 2vR raises the product disagreement rate to 4.72% at M=8M = 8 and 3.12% at M=16M = 16 (mean over 10 seeds). Since the deletion also breaks equidistance, the sum rate rises similarly (5.26%, 4.48%).

To verify the main theorem pair by pair, we took all 977 class pairs of 49 codes (nvR-type codes; Hadamard M∈{4,8,12,16}M \in\{4, 8, 12, 16\}, with M=12M = 12 of Paley type; logM; 24 random codes; and 10 codes obtained from nvR codes by row deletion) and independently (a) tested pair structure (Lemma 3) and (b) searched for π\pi at which the product decoder strictly reverses the MAP order (sampling near ties and local optimization).

Every reversal candidate was confirmed with the original decoding formula. Reversals were found for all 773 pairs without pair structure and for none of the 204 pairs with it. Among Hadamard codes, all pairs had pair structure for M=4M = 4 and none for M=8,12,16M = 8, 12, 16 (consistent with Proposition 3).

B: Size of the reversal margin

We measured the reversal margin of Hadamard codes for M∈{8,12,16,20,28,32,48,64}M \in\{8, 12, 16, 20, 28, 32, 48, 64\} in the typical case (Dirichlet sampling, Gaussian data) and the worst case (multi-start SLSQP; Figure 3). The typical value (largest δ∗\delta^{*} at sampled disagreement points) roughly decays from 0.0135 (M=8M = 8) to about 0.003 (M=48,64M = 48, 64), whereas the worst case stays within [0.017,0.025][0.017, 0.025] for all MM, from 1.3 times the typical (Dirichlet) value at M=8M = 8 to about 9 times at M=48,64M = 48, 64. Over 500,000 noiseless samples for M∈{8,16,32}M \in\{8, 16, 32\}, the true MAP margin at disagreement points was at most 0.00845 (0.51 times the construction value 0.0166). Random posteriors rarely hit the worst-case construction (a corner of the simplex).

Figure 3. Dependence of the reversal margin on MM (Hadamard codes). Typical values (largest margin at disagreement points found by Dirichlet sampling and Gaussian data) roughly decay with MM; the worst values found by local SLSQP search stay within [0.017,0.025][0.017, 0.025] regardless of MM. Red dashed line: the largest MAP margin 0.911δˉ0.911 \bar{\delta} with argmax disagreement in the construction of Theorem 2; triangles: Sylvester-type MM (to which the theorem applies).

C: Which decoder is more accurate with real classifiers?

We compared the decoders under estimated probabilities on six datasets (letter, isolet, pendigits, MNIST, Fashion-MNIST, MobileNetV2 features of CIFAR-100). For random class subsets with M∈{8,16,24,32}M \in\{8, 16, 24, 32\} (as the data allow), logistic regression was trained for each column of 1-vs-Rest, 2vR, Hadamard, and random dense codes (n=⌈10log⁡2M⌉n = \lceil10\log_{2} M\rceil). Each column was temperature-calibrated on validation data (“calibrated” below), and calibration error was then introduced by scaling the logits (a) of all columns by a common factor γ∈{0.5,1,2,4}\gamma\in\{0.5, 1, 2, 4\} (γ>1\gamma> 1: uniform overconfidence), or (b) by column-specific factors γj=exp⁡(σgj)\gamma_j = \exp(\sigma g_j), gj∼N(0,1)g_j \sim\mathcal{N}(0, 1), σ∈{0.1,0.2,0.5,1}\sigma\in\{0.1, 0.2, 0.5, 1\} (calibration error varying across columns). We compared test accuracies over 5 seeds per condition. Condition (a) and the hypotheses were fixed before the runs; (b) is exploratory, added after seeing (a). On 1-vs-Rest the decoders coincide identically (both take the argmax of the logit of column mm), so we report the other codes.

Figure 4 shows the results. When calibrated, the product decoder was more accurate: by +0.3 to +0.4 points for all codes (95% bootstrap confidence intervals excluding 0), and significantly better by McNemar’s test in 24 of the 39 cells (dataset, MM, code), the sum decoder in none. Uniform overconfidence widens the product advantage (+0.9 to +1.8 points at γ=4\gamma= 4). The product decision, a signed sum of logits (Eq. (5)), is unchanged by a common factor. The sum decoder, in contrast, moves toward a Hamming-distance majority vote as the sigmoid saturates, which is consistent with its loss of accuracy. Calibration error varying across columns reverses the sign. At σ=1\sigma= 1 the sum decoder was better by 0.9 to 2.0 points, significantly in 36 of the 39 cells. This is consistent with how the decoders weight the votes: the product decoder weights confident columns heavily (§ 3), so overconfidence in a few columns can dominate its decision, whereas the sum votes are bounded in [−1,1][-1,1]. We did not model how the column errors combine; § 8 lists this as future work. The reversal was largest on Hadamard codes.

Figure 4. Accuracy difference between the product and sum decoders with real classifiers (points; positive means the product decoder is more accurate). Means and 95% bootstrap confidence intervals over six datasets, each MM, and 5 seeds. (a) All logits multiplied by a common factor γ\gamma: the product decision is unchanged, while the sum decoder degrades as γ\gamma grows. (b) Column-specific factors γj=exp⁡(σgj)\gamma_j = \exp(\sigma g_j): as the spread grows, the sum decoder becomes better.

The estimated margin at disagreement points (the gap between the top two sum scores) was small, about 7% of the overall mean (median), and below the overall mean in all 139 of the 156 (dataset, MM, code, γ\gamma) conditions with at least 20 disagreements: disagreements concentrate near ties.

Discussion

Which decoder should be used?

By the criterion of noiseless consistency the answer is clear. Exact MAP-consistency requires an equidistant code for the sum decoder (Proposition 1) and a code with pair structure, that is, a union of nvRnvR codes, for the product decoder (Theorem 1), and pair structure implies equidistance (Corollary 3). The sum decoder is thus safe on a wider class of codes. In particular, the Hadamard code is an efficient equidistant code with distance M/2M/2 and length M−1M - 1, but for M≥8M \ge8 it has no pair structure (Proposition 3); with a Hadamard code, choose the sum decoder if exact consistency is needed. The nvRnvR codes are consistent for both decoders, but column deletion breaks pair structure and equidistance (Experiment A), so the code must be used in full.

Product reversals matter only in a limited range. δˉ≈0.018\bar{\delta} \approx0.018 is a proven lower bound showing that the reversal margin can be this large (Theorem 2), not an upper bound guaranteeing safety; local search has found reversals up to 0.025. Under random posteriors the MAP margin at disagreement points was at most about half of the construction value (Experiment B); either way, reversals are confined to near ties, where the posteriors are nearly equal.

Under estimation error the picture changes (Experiment C). With calibrated logistic regression the product decoder is slightly more accurate, and its decision is unchanged under uniform overconfidence of all columns; when the calibration error differs across columns, the sum decoder is better. This is consistent with the product decoder reading the votes as unbounded log-odds and the sum decoder as bounded probabilities. In practice, use the product decoder if the probability of each column can be calibrated individually, and the sum decoder if the calibration quality varies across columns (or cannot be checked). Either way the difference is within about 2 points (0.3–0.4 points when calibrated), and disagreements are confined to near ties. The claim of Kittler et al. (1998) that the sum is robust to estimation error can be read as robustness to calibration error varying across columns.

Limitations and future work

Our theory assumes the noiseless setting p=CTπ\mathbf{p} = C^{\mathsf{T}}\boldsymbol{\pi}, which separates the decoding rule and the code structure from classifier error but does not hold for real classifiers: under estimated probabilities, even 2vR2vR, on which both decoders agree with MAP in the noiseless setting, yields different sum and product decisions (Experiment C). How robust equidistance and pair structure are to estimation error is unknown. Experiment C suggests that, under estimation error, which decoder wins may depend on how the column errors combine; analyzing this through error exponents (reliability functions) is future work.

For the reversal margin of Hadamard codes, open problems are (1) the exact worst MAP margin with argmax disagreement (at least 0.0166; local search found at most 0.025) and an analytic derivation of the threshold 0.911δˉ0.911\bar{\delta} in the construction (currently only numerical); (2) the lower-bound constant for non-Sylvester types (numerically, a similar Θ(10−2)\Theta(10^{-2}) is observed); and (3) the exact rate of decay in the typical case.

Conclusion

We have characterized the MAP-consistency of the product decoder in ECOC under the noiseless setting p=CTπ\mathbf{p} = C^{\mathsf{T}}\boldsymbol{\pi}. Reading a class-pair comparison as a sample of votes, the sum decoder decides by the sample mean and the product decoder by an M-estimator through artanh⁡\operatorname{artanh}, and for every code each vote is the MAP margin plus a bias determined by the background alone. The sum decoder is MAP-consistent if and only if the code is equidistant (James & Hastie, 1998b) (Proposition 1). Our main theorem (Theorem 1): the product decoder is MAP-consistent if and only if every class pair has pair structure, which strengthens the sufficient symmetry condition of prior work (Kumoi et al., 2021) to a necessary and sufficient one, and if and only if the code is a union of nvRnvR codes. Every product-consistent code is sum-consistent (Corollary 3). Hadamard codes (M≥8M \ge8), which meet the Plotkin bound, have no pair structure because their columns are orthogonal (Proposition 3), and for the Sylvester type the reversal margin can be at least a constant δˉ≈0.018175\bar{\delta} \approx0.018175 independent of MM (Theorem 2). For MM not a multiple of four, row deletion gives equidistant codes at a cost of at most three extra columns.

Experiments confirmed Proposition 1 on the codes of Experiment A and the main theorem on 977 class pairs. Under estimation error, the product decoder was slightly more accurate when each column was calibrated, and the sum decoder was better when the calibration error differed across columns; with real classifiers it appears safe to choose the product decoder if the calibration of each column can be checked, and the sum decoder otherwise. The core difference between the two decoders is that the sum decoder requires only first-moment balance of the votes (equidistance), whereas the product decoder requires symmetry of the whole vote distribution (pair structure), and this symmetry leaves only the nvRnvR codes.

Acknowledgments

The author is deeply grateful to Shigeichi Hirasawa, Manabu Kobayashi, and Hideki Yagi for many years of seminar discussions; this paper is the culmination of the discussions that began with the earlier work (Kumoi et al., 2021). This work was supported by JSPS KAKENHI Grant Number JP24K20833.

Proofs from the Main Text

Proof of Proposition 2. When π\pi is in the relative interior, 0<qi<10<q_i<1, so β+aj=zj∈(−1,1)\beta+a_j=z_j\in(-1,1) and Ψb′(β)=∑j∈T(1−(β+aj)2)−1>0\Psi_b'(\beta)=\sum_{j\in T}(1-(\beta+a_j)^2)^{-1}>0. Ψb\Psi_b is defined on the open interval B=(−1−min⁡jaj,1−max⁡jaj)B=(-1-\min_j a_j,1-\max_j a_j) on which β+aj∈(−1,1)\beta+a_j\in(-1,1) for all jj, and it diverges to −∞-\infty at the left endpoint and +∞+\infty at the right endpoint, so it has a unique root on BB. Since ∣aj∣≤∑kbk=1−r|a_j|\leq\sum_k b_k=1-r, we have (−r,r)⊂B(-r,r)\subset B.

The product decoder prefers mm iff Ψb(β)>0\Psi_b(\beta)>0, and MAP prefers mm iff β>0\beta>0. (1) If Ψb(0)=0\Psi_b(0)=0, monotonicity gives sign⁡Ψb(β)=sign⁡β\operatorname{sign}\Psi_b(\beta)=\operatorname{sign}\beta. (2) If Ψb(0)>0\Psi_b(0)>0, the root lies at β∗<0\beta^*<0; for β∈(β∗,0)\beta\in(\beta^*,0) the reversal Ψb(β)>0>β\Psi_b(\beta)>0>\beta occurs, and for β∉[β∗,0]\beta\notin[\beta^*,0] the signs agree. Since β\beta on the family is restricted to (−r,r)(-r,r), the reversal interval is (max⁡(β∗,−r),0)(\max(\beta^*,-r),0), which is nonempty because max⁡(β∗,−r)<0\max(\beta^*,-r)<0.

Proof of Theorem 2. Fix any class m≠0m \ne0 and take the class pair (0,m)(0,m). Since c0=1c_0=1, T={j:cmj=0}T=\{j:c_{mj}=0\} and ∣T∣=M/2|T|=M/2; in the character form of Proposition 4, T={j:χm(j)=−1}T=\{j:\chi_m(j)=-1\}, and the agreement sign of a background class kk is τkj=2ckj−1=χk(j)\tau_{kj}=2c_{kj}-1=\chi_k(j). Choose linearly independent b1,b2∈F2r∖{0,m}b_1,b_2\in\mathbb{F}_2^r\setminus\{0,m\} with b1⊕b2≠mb_1\oplus b_2\ne m (possible for M≥8M\ge8) and let b3:=b1⊕b2b_3:=b_1\oplus b_2. Place background mass ρ=1/5\rho=1/5 on each element of the triple and set the other background classes to 0. Then π0+πm=2/5\pi_0+\pi_m=2/5 and β=π0−πm\beta=\pi_0-\pi_m.

By Lemma 1, the bias is aj=ρ(χb1(j)+χb2(j)+χb3(j))a_j=\rho(\chi_{b_1}(j)+\chi_{b_2}(j)+\chi_{b_3}(j)). By the product rule χb3=χb1χb2\chi_{b_3}=\chi_{b_1}\chi_{b_2}, χb1+χb2+χb3=(1+χb1)(1+χb2)−1∈{3,−1}\chi_{b_1}+\chi_{b_2}+\chi_{b_3}=(1+\chi_{b_1})(1+\chi_{b_2})-1\in\{3,-1\}, taking the value 3 only when χb1=χb2=1\chi_{b_1}=\chi_{b_2}=1. Since m,b1,b2m,b_1,b_2 are linearly independent, (χb1,χb2)(\chi_{b_1},\chi_{b_2}) is uniformly distributed on {±1}2\{\pm1\}^2 over T={χm=−1}T=\{\chi_m=-1\}. Hence

aj∈{+0.6 (proportion 1/4), −0.2 (proportion 3/4)},⟨a⟩=0,a_j\in\{+0.6\ \text{(proportion }1/4),\,-0.2\ \text{(proportion }3/4)\},\qquad\langle a\rangle=0,

and Ψb(β)=s4artanh⁡(β+0.6)+3s4artanh⁡(β−0.2)\Psi_b(\beta)=\frac{s}{4}\operatorname{artanh}(\beta+0.6)+\frac{3s}{4}\operatorname{artanh}(\beta-0.2), Ψb(0)=s[14artanh⁡0.6+34artanh⁡(−0.2)]≈0.0212s>0\Psi_b(0)=s\left[\frac{1}{4}\operatorname{artanh}0.6+\frac{3}{4}\operatorname{artanh}(-0.2)\right]\approx0.0212s>0. By Proposition 2(2) there is a root β∗<0\beta^*<0. Writing β∗=−δ\beta^*=-\delta and using the odd symmetry of artanh⁡\operatorname{artanh}, the root equation becomes artanh⁡(0.6−δ)=3artanh⁡(0.2+δ)\operatorname{artanh}(0.6-\delta)=3\operatorname{artanh}(0.2+\delta), i.e., Eq. (10), which does not involve ss. Since r=2/5>δˉr=2/5>\bar{\delta}, the reversal interval is β∈(−δˉ,0)\beta\in(-\bar{\delta},0), i.e., 0<πm−π0<δˉ0<\pi_m-\pi_0<\bar{\delta}. Then πm=(2/5+ϵ)/2>1/5\pi_m=(2/5+\epsilon)/2>1/5 exceeds the triple masses 1/51/5 and π0\pi_0, so mm is the MAP class.

This construction has mass on only five classes and lies on the boundary of the simplex. Distribute a small mass η>0\eta>0 uniformly over the remaining M−5M-5 classes and scale the five masses by 1−(M−5)η1-(M-5)\eta to obtain πη\pi_\eta. Each pjp_j on TT is continuous in η\eta, and at η=0\eta=0 the values pj∈{0.4,0.8}p_j\in\{0.4,0.8\} are bounded away from the endpoints. For fixed ϵ∈(0,δˉ)\epsilon\in(0,\bar{\delta}) the reversal and the fact that mm is the MAP class hold at η=0\eta=0 with strict inequalities, so they persist for all sufficiently small η>0\eta>0 (the scaling turns πm−π0\pi_m-\pi_0 into ϵ(1−(M−5)η)\epsilon(1-(M-5)\eta); starting from ϵ/(1−(M−5)η)\epsilon/(1-(M-5)\eta) restores ϵ\epsilon).

Proof of (2)⇒(3) in the Main Theorem

Suppose some class pair (m,m′)(m,m') lacks pair structure, and assume weak consistency; we derive a contradiction. Let U:={b:bk>0, ∑kbk<1}U:=\{b:b_k>0,\ \sum_k b_k<1\} be the set of admissible backgrounds.

Step 1. Ψb(0)=0\Psi_b(0)=0 for every b∈Ub\in U. Indeed, if Ψb(0)>0\Psi_b(0)>0 for some b∈Ub\in U, Proposition 2(2) (and, if Ψb(0)<0\Psi_b(0)<0, the same proposition with m↔m′m\leftrightarrow m') gives a strict reversal of the MAP order on a nonempty interval of β\beta, contradicting weak consistency.

Step 2 (a single ray). Number the background classes k1,…,kM−2k_1,\ldots,k_{M-2} and set vki:=2i−1/2Mv_{k_i}:=2^{i-1}/2^M. Since vk>0v_k>0 and ∑kvk<1\sum_k v_k<1, we have tv∈Utv\in U for t∈(0,1)t\in(0,1), and Step 1 gives

∑j∈Tartanh⁡(tuj)=0,uj:=⟨v,τj⟩∈(−1,1).\sum_{j\in T}\operatorname{artanh}(t u_j)=0,\qquad u_j:=\langle v,\tau_j\rangle\in(-1,1).

For ∣t∣<1|t|<1 the left side equals the convergent power series ∑κ oddtκκ∑j∈Tujκ\sum_{\kappa\ \mathrm{odd}}\frac{t^\kappa}{\kappa}\sum_{j\in T}u_j^\kappa, an odd function of tt. It therefore vanishes on all of (−1,1)(-1,1), and uniqueness of power-series coefficients gives ∑j∈Tujκ=0\sum_{j\in T}u_j^\kappa=0 for every odd κ\kappa.

Step 3 (symmetry). Let SS be the finite set of the values ±uj\pm u_j and ν(x):=#{j∈T:uj=x}−#{j∈T:uj=−x}\nu(x):=\#\{j\in T:u_j=x\}-\#\{j\in T:u_j=-x\}. For odd κ\kappa, ∑x∈Sν(x)xκ=2∑j∈Tujκ=0\sum_{x\in S}\nu(x)x^\kappa=2\sum_{j\in T}u_j^\kappa=0; for even κ\kappa the two terms cancel. These equations for κ=0,1,…,∣S∣−1\kappa=0,1,\ldots,|S|-1 imply ν=0\nu=0 by the nonsingularity of the Vandermonde matrix, i.e., the multiset {uj}j∈T\{u_j\}_{j\in T} is symmetric about 0.

Step 4 (back to patterns). With AjA_j the set of background classes with τkj=+1\tau_{kj}=+1, uj=2−M(2i−1−(2M−2−1))u_j=2^{-M}\left(2^{i-1}-\left(2^{M-2}-1\right)\right). By uniqueness of binary expansions, uju_j determines AjA_j and hence τj\tau_j, and −uj-u_j corresponds to −τj-\tau_j. Hence the multiset of agreement patterns is invariant under sign flip, and by Lemma 3 the class pair has pair structure, a contradiction. □\square

Experimental Details

Table 2 summarizes the main settings of the experiments in § 7.

Exp.Main settings
ANoiseless agreement: 1-vs-Rest, 2vR, half-vs-half, Hadamard, log⁡M×M∈{4,8,16,32}\log M \times M \in\{4, 8, 16, 32\}; four series (Dirichlet α∈{0.3,1}\alpha\in\{0.3, 1\} and two derived from Gaussian data), 200,000 samples each (100,000 for codes with many columns); column deletion k=1,2k = 1, 2 from 2vR (10 seeds); pair-structure check on 49 codes and 977 class pairs
A′Row deletion (Corollary 2): two rows deleted from Hadamard M=12M = 12 to give M=10M = 10 (equal-weight and unequal-weight cases); Dirichlet α∈{0.3,1}\alpha\in\{0.3, 1\}, 50,000 samples each; zero sum-decoder disagreements
BHadamard M∈{8,12,16,20,28,32,48,64}M \in\{8, 12, 16, 20, 28, 32, 48, 64\}; typical values (largest margin at disagreement points) from Dirichlet α∈{0.3,1}\alpha\in\{0.3, 1\} (50,000 × 3 seeds) and Gaussian data (20,000 × 4 variances ×3 seeds); worst values by multi-start SLSQP (maximum over 100 starts × 3 seeds); margin distribution at disagreement points from 500,000 noiseless samples for M∈{8,16,32}M \in\{8, 16, 32\}
Cletter, isolet, pendigits, MNIST and Fashion-MNIST (PCA-50, at most 1500 per class), CIFAR-100 (MobileNetV2 features, PCA-100); M∈{8,16,24,32}M \in\{8, 16, 24, 32\} (as far as the number of classes allows); class subsets and splits (train/validation/test = 60/20/20) varied over 5 seeds; per-column logistic regression (inverse regularization strength 1, standardized features) with temperature calibration on validation data; (a) common factor γ∈{0.5,1,2,4}\gamma\in\{0.5, 1, 2, 4\}, (b) column-specific factors γj=exp⁡(σgj)\gamma_j = \exp(\sigma g_j), σ∈{0,0.5,1}\sigma\in\{0, 0.5, 1\} (3 draws each). The hypotheses and the design of (a) were fixed before the runs

Table 2. Experimental settings.

Reproducibility. The Lean 4 formalization of all theorems, lemmas, propositions, and corollaries is provided in the ancillary files of this arXiv submission. The numerical claims are confirmed by verification scripts, and the code to reproduce the experiments will be released in a public repository after acceptance. The product score is computed as the sum of the Bernoulli log-likelihoods of the binary-classifier outputs (Eq. (3)), i.e., the exact log-likelihood rule rather than a log⁡(1+p)\log(1+p)-type approximation. CIFAR-100 features are extracted once and cached for reuse.

References

  1. [1]Erin L. Allwein, Robert E. Schapire, and Yoram Singer. Reducing multiclass to binary: A unifying approach for margin classifiers. Journal of Machine Learning Research, 1:113–141, 2000.
  2. [2]Lorena Álvarez-Pérez and Álvaro Callejas-Ramos. Walsh sequences as direct error correcting output code dichotomies for multiclass problems. Engineering Applications of Artificial Intelligence, 173:114442, 2026. doi: 10.1016/j.engappai.2026.114442.
  3. [3]Morris H. DeGroot and Julia Mortera. Optimal linear opinion pools. Management Science, 37(5):546–558, 1991. doi: 10.1287/mnsc.37.5.546.DOI
  4. [4]Thomas G. Dietterich and Ghulam Bakiri. Solving multiclass learning problems via error-correcting output codes. Journal of Artificial Intelligence Research, 2:263–286, 1995. doi: 10.1613/jair.105.DOI

Paper details

vlnc:W_ycwz4w35
Version
v1 · latest
Published
Fresh — added to the Hub within the last 30 days
Added
License
CC BY 4.0
Usage

views · 0

downloads · 0

A view counts once per browser per day, a download each time the PDF is requested.

  • Computer Science

Not recorded for this paper

View statement
Looking for related papers…
Contents