← Lab
grandmean
confirmedupstream bugPython · evaluateInference, serving & evaluationJuly 24, 2026
the question
Does HuggingFace evaluate's mahalanobis metric center inputs with a per-feature mean?
what came out
HuggingFace evaluate mahalanobis.py centers with X - np.mean(reference_distribution), the scalar grand mean, against a per-feature np.cov, so the quadratic form mixes bases. A point at the distribution center gets D^2=52.48 instead of 0, and error grows with feature-mean spread. Fix is np.mean(..., axis=0). First reported in evaluate#470 and #471 (July 2023), still unmerged.
method & receipts
- Result: confirmed
- Reproducible: one script re-runs the whole thing from scratch.
- Tested: a correctness/benchmark suite ships alongside the code.
→ read the code and re-run it
github.com/v-code01/grandmean