ELVIA.Evidence Atlas
ICML 2025ELVIA assessment Major

Mahalanobis++: Improving OOD Detection via Feature Normalization

Maximilian Müller, Matthias Hein

ELVIA analysis

Independent review pending

The released normalized-relative Mahalanobis evaluator can mix normalized class statistics with unnormalized global statistics under its prescribed evaluation order. A fully specified example with positive-definite covariances reverses two sample rankings, establishing a Major implementation defect for that reported variant. The primary Mahalanobis++ path and the separate CIFAR relative implementation avoid this defect; historical table effects remain unverified. A Gaussian-moment basis omission and limited numerical summary errors are Minor. The principal 41/44 improvement count, variance-deviation identity, and selected aggregate arithmetic check out within the inspected scope. Scientific adjudication is pending.

Problem 1. Cache-dependent normalized-relative score mixes feature coordinates

Major
Evidence and reasoning

Problem statement

For training features xi∈Rd,x_i\in\mathbb R^d, labels ci,c_i, and nonempty classes, the paper estimates μc=Nc−1∑i:ci=cxi,C=N−1∑i(xi−μci)(xi−μci)⊤.\mu_c=N_c^{-1}\sum_{i:c_i=c}x_i,\qquad C=N^{-1}\sum_i(x_i-\mu_{c_i})(x_i-\mu_{c_i})^\top . The primary score is sM(z)=−min⁡c(z−μc)⊤C−1(z−μc).s_M(z)=-\min_c(z-\mu_c)^\top C^{-1}(z-\mu_c). Larger scores indicate more ID-like inputs. The evaluation uses a threshold at 95%95\% ID true-positive rate. Mahalanobis++ applies x↦x/∥x∥2x\mapsto x/\|x\|_2 to both fitting and test features (Section 4, Equation (6)). The relative version additionally fits global mean gg and covariance G,G, without class centering, and uses sR(z)=−min⁡c(z−μc)⊤C−1(z−μc)+(z−g)⊤G−1(z−g). s_R(z)=-\min_c(z-\mu_c)^\top C^{-1}(z-\mu_c) +(z-g)^\top G^{-1}(z-g). This is Appendix GG’s definition on page 34. Page 7 introduces relative Mahalanobis++ by applying feature normalization to that construction. Its columns recur throughout the main and appendix results. The implementation issue below concerns that specific normalization-dependent score.

Relative Mahalanobis++ applies feature normalization to both class and global fits before evaluating the relative score.

Nonzero features; all 1,0001{,}000 classes nonempty. Normalized class caches exist; normalized global caches do not; caller supplies raw training features. Every covariance in the witness is positive definite; score is the paper's finite-feature estimator.

Proof

In `NINCO/detection_methods.py`, `evaluate_Relative_Mahalanobis_norm`, lines 548548–662,662, training normalization is conditional on missing class-statistic caches. A later, separately conditioned global fit can consequently use raw features while the class fit and test features are normalized.

Test features are normalized at lines 569569–570.570. Lines 572572–580580 load `mean_norm.npy` and `prec_norm.npy`. Training normalization at line 585585 lies inside the branch at line 583583 that runs only if these class statistics are incomplete. Global caches are checked separately at lines 607607–617;617; on a miss, lines 623623–629629 estimate their mean and covariance directly from the current training array.

This state occurs in the documented workflow. README line 100100 recommends `–method all`. `NINCO/evaluate.py`, lines 2828–37,37, places `Mahalanobis_norm` before `Relative_Mahalanobis_norm`; line 416416 selects this list. The loop at line 244244 passes the same stored raw training array (assigned at line 109109) and per-model cache path (line 217217) to the two functions at lines 274274–287.287. The first function normalizes by local rebinding at `detection_methods.py`:453 and saves the class caches at lines 468468–469.469. It does not modify the caller’s raw array in place. The relative call then skips training normalization and, if its global caches are absent, fits a raw global Gaussian under normalized-cache filenames.

Take 1,0001{,}000 classes with three raw training features each. In 500500 classes use A={(2,0),(0,2),(−2,0)};A=\{(2,0),(0,2),(-2,0)\}; in the other 500500 use B={(2,0),(0,−2),(−2,0)}.B=\{(2,0),(0,-2),(-2,0)\}. All 3,0003{,}000 vectors are nonzero, every class is nonempty, and the construction respects the source’s hard-coded 11,000-class loop. It tests the finite-feature estimator, which is defined without requiring the empirical features to be exactly Gaussian.

After normalization, the two distinct class means are μA=(0,1/3),μB=(0,−1/3),\mu_A=(0,1/3),\qquad \mu_B=(0,-1/3), and direct centered sums give C=diag⁡(2/3,2/9),g=0,G=diag⁡(2/3,1/3).C=\operatorname{diag}(2/3,2/9),\qquad g=0,\qquad G=\operatorname{diag}(2/3,1/3). The raw global covariance is Graw=4G,G_{\rm raw}=4G, with the same zero mean. All three covariance matrices are positive definite. Let u=(0,1)u=(0,1) and v=(4/5,3/5);v=(4/5,3/5); both already have unit norm. Exact arithmetic yields:

Quantity | u∣vu | v

Minimum normalized class distance | 2∣32/252 | 32/25

Correct normalized global distance | 3∣51/253 | 51/25

Raw-global distance at normalized test point | 3/4∣51/1003/4 | 51/100

Correct relative score | 1∣19/251 | 19/25

Mixed-coordinate relative score | −5/4∣−77/100-5/4 | -77/100

Thus the correct method ranks uu above v,v, but the mixed fit ranks uu below v.v. The discrepancy is not a common additive offset or an increasing transformation that would leave ranking metrics unchanged. The independent check verified these fractions symbolically and separately fitted the covariance matrices from the explicit 33,000-row synthetic array. Neither computation called author code.

□\square

Possible revision

Normalize training features before either fit and rebuild affected global/statistic-dependent score caches with explicit provenance.

Problem 2. Gaussian variance expansion omits the rotated mean

Minor
Evidence and reasoning

Problem statement

For training features xi∈Rd,x_i\in\mathbb R^d, labels ci,c_i, and nonempty classes, the paper estimates μc=Nc−1∑i:ci=cxi,C=N−1∑i(xi−μci)(xi−μci)⊤.\mu_c=N_c^{-1}\sum_{i:c_i=c}x_i,\qquad C=N^{-1}\sum_i(x_i-\mu_{c_i})(x_i-\mu_{c_i})^\top . The primary score is sM(z)=−min⁡c(z−μc)⊤C−1(z−μc).s_M(z)=-\min_c(z-\mu_c)^\top C^{-1}(z-\mu_c). Larger scores indicate more ID-like inputs. The evaluation uses a threshold at 95%95\% ID true-positive rate. Mahalanobis++ applies x↦x/∥x∥2x\mapsto x/\|x\|_2 to both fitting and test features (Section 4, Equation (6)). The relative version additionally fits global mean gg and covariance G,G, without class centering, and uses sR(z)=−min⁡c(z−μc)⊤C−1(z−μc)+(z−g)⊤G−1(z−g). s_R(z)=-\min_c(z-\mu_c)^\top C^{-1}(z-\mu_c) +(z-g)^\top G^{-1}(z-g). This is Appendix GG’s definition on page 34. Page 7 introduces relative Mahalanobis++ by applying feature normalization to that construction. Its columns recur throughout the main and appendix results. The implementation issue below concerns that specific normalization-dependent score.

Lemma 3.1 defines the squared-norm variance using covariance eigenvalues and unqualified original mean coordinates.

X is Gaussian; Sigma positive definite. Original mean coordinates are not silently redefined after rotation.

Proof

The printed variance numerator uses eigenvalues λi\lambda_i of Σ\Sigma paired with coordinates μi,\mu_i, without specifying that the mean is expressed in the covariance eigenbasis.

For X∼N(μ,Σ),X\sim\mathcal N(\mu,\Sigma), the coordinate-invariant formulas are E∥X∥22=tr⁡Σ+∥μ∥22,Var⁡(∥X∥22)=2tr⁡(Σ2)+4μ⊤Σμ=∑i{2λi2+4λi(U⊤μ)i2},Σ=Udiag⁡(λi)U⊤.\begin{aligned} \mathbb E\|X\|_2^{2}&=\operatorname{tr}\Sigma+\|\mu\|_2^{2},\\ \operatorname{Var}(\|X\|_2^{2}) &=2\operatorname{tr}(\Sigma^{2})+4\mu^\top\Sigma\mu\\ &=\sum_i\{2\lambda_i^{2}+4\lambda_i(U^\top\mu)_i^{2}\}, \quad \Sigma=U\operatorname{diag}(\lambda_i)U^\top .\end{aligned} These follow by expanding independent Gaussian coordinates after orthogonal rotation. The lemma instead prints ∑i(2λi2+4λiμi2).\sum_i(2\lambda_i^{2}+4\lambda_i\mu_i^{2}). For Σ=(2112),μ=(1,0),\Sigma=\begin{pmatrix}2&1\\1&2\end{pmatrix},\qquad \mu=(1,0), the actual variance is 28.28. Pairing the original mean coordinates with eigenvalues 1,31,3 gives 24,24, or 3232 after reversing their order. An invariant variance cannot depend on that ordering.

Appendix B explicitly states the correct rotated mean U⊤μU^\top\mu before later writing μi.\mu_i. This is decisive counterevidence: reading those later coordinates in the eigenbasis restores the moment calculation and Chebyshev argument. The supported defect is a local mathematical statement/notation omission, not a failure of Gaussian norm analysis or a demonstrated violation of the claimed probability bound for a particular threshold. Replacing the numerator by the invariant expression above is analytically verified. No empirical result was shown to depend on the erroneous coordinate reading.

□\square

Possible revision

Use the invariant expression or explicitly replace μi\mu_i by (U⊤μU^\top\mu)_i.

Problem 3. Universal comparator wording and model-win count exceed displayed results

Minor
Evidence and reasoning

Problem statement

For training features xi∈Rd,x_i\in\mathbb R^d, labels ci,c_i, and nonempty classes, the paper estimates μc=Nc−1∑i:ci=cxi,C=N−1∑i(xi−μci)(xi−μci)⊤.\mu_c=N_c^{-1}\sum_{i:c_i=c}x_i,\qquad C=N^{-1}\sum_i(x_i-\mu_{c_i})(x_i-\mu_{c_i})^\top . The primary score is sM(z)=−min⁡c(z−μc)⊤C−1(z−μc).s_M(z)=-\min_c(z-\mu_c)^\top C^{-1}(z-\mu_c). Larger scores indicate more ID-like inputs. The evaluation uses a threshold at 95%95\% ID true-positive rate. Mahalanobis++ applies x↦x/∥x∥2x\mapsto x/\|x\|_2 to both fitting and test features (Section 4, Equation (6)). The relative version additionally fits global mean gg and covariance G,G, without class centering, and uses sR(z)=−min⁡c(z−μc)⊤C−1(z−μc)+(z−g)⊤G−1(z−g). s_R(z)=-\min_c(z-\mu_c)^\top C^{-1}(z-\mu_c) +(z-g)^\top G^{-1}(z-g). This is Appendix GG’s definition on page 34. Page 7 introduces relative Mahalanobis++ by applying feature normalization to that construction. Its columns recur throughout the main and appendix results. The implementation issue below concerns that specific normalization-dependent score.

All considered cosine/KNN cases improve; Table4 has30/44 Maha++ wins; relative normalization improves across models/datasets.

Proof

Some universal comparator wording and one model-win count disagree with the paper’s own numerical tables.

Page 6 says the method outperforms KNN and cosine similarity in all considered cases. Table 12, page 26, gives EffNetV2-S FPR 59.959.9 for Maha++ versus 58.858.8 for cosine, and ResNet50-supcon 59.659.6 versus 58.958.9 for cosine and 58.458.4 for NNguide. On CIFAR100 RN34, Tables 3 and 16 give Maha++ 74.5174.51 versus KNN 74.44.74.44. Lower FPR is better. Likewise, page 7’s claim that relative normalization improves across models and datasets has exceptions in Table 2: iNaturalist 2.0→2.22.0\to2.2 for ConvNeXtV2-B and 3.5→3.93.5\to3.9 for SwinV2-B.

Independent enumeration of the 4444 displayed Table 4 rows gives 2929 Maha++ winners, 66 relative-Maha++ winners, 55 ViM winners, 33 unnormalized-Maha winners, and 11 Ash winner, with no displayed minimum ties. Page 7 instead states 30/4430/44 for Maha++. The full row-wise count is retained in the calculation evidence.

The appendix openly acknowledges comparator exceptions, and the main text acknowledges the three failures to improve ordinary Maha. The correction is therefore to qualify the universal wording and reconcile the 29-versus-30 summary, not to reject the demonstrated average advantage. Original unrounded measurements were not available; rounding of aggregate means is not treated as an additional error.

□\square

Possible revision

Qualify comparator statements and reconcile the count with the displayed table.

Supporting record & provenance

Work status

Current version

Version 1

Minhao Liu · Initial report · Version 1

Independent review pending

Original claim and review scope

We show below that Mahalanobis++ outperforms KNN and cosine similarity in all considered cases and, in particular, improves OOD detection consistently across tasks, architectures, training methods and OOD datasets as post-hoc method.

Published ICML 2025 proceedings PDF (PMLR 267); PDF p. 6

Actual review scope

The recorded inspection concerns these source locations: Paper p. 7 and Appendix G p. 34; NINCO/detection_methods.py:548–662; evaluate.py:28–37,109,217,244,274–287,416; README:100.; p. 4 Lemma 3.1; Appendix B pp. 13–14; pp. 6–7; Tables2–4 and12/16.

Submit an author revisionContribute a review