arXiv:2610.30456cs.LGOct 2026

Manuscript Offprint

arXiv:2610.30456

aggmetrics: Aggregating Classification Performance Measures for Machine Learning

Ronaldo Cristiano Prati

Open access. PaperVantage converted this article to text, so layout and figures may differ from the original.

Abstract

aggmetrics is a Python package that extends any binary performance measure expressed in the four confusion-matrix counts to multiclass, multilabel, ordinal, cost-sensitive, soft-label and cross-validation settings, by substituting one of four aggregation operators for what libraries usually expose as an average switch. The package also stores, for every measure, the structural properties that decide which identities apply to it, can infer those properties from a user-supplied formula, and uses them to warn when a measure is used where it does not behave as commonly assumed. Its test suite encodes the results of the companion theory as executable tests. The package is BSD-3 licensed, depends only on NumPy, and is available at https://github.com/rcprati/aggmetrics; documentation at https://aggmetrics.readthedocs.io.

Keywords: classification, performance measures, evaluation, class imbalance, multilabel, Python

1. Introduction

Reporting a classifier’s performance involves two choices that are made separately in practice: which measure to use, and how to aggregate it over classes, examples or cross-validation folds. In scikit-learn (Pedregosa et al., 2011) the second choice is an average argument attached to a fixed list of functions, so a combination outside that list (a macro-averaged Matthews correlation coefficient, an exemplar-averaged Jaccard index) has to be written by hand. More importantly, a function returns a float whether or not the evaluation setting suits the measure. Two examples reproducible with the package illustrate the problem.

Floors. Under one-hot encoding of an m-class problem, each misclassified example still contributes m−2m - 2 true negatives. On a 10-class problem, a classifier that is wrong on every example scores 0.800 on label accuracy and -0.111 on MCC (micro-averaged), rather than 0 and -1. Measures that depend on the true negatives at tp=0tp = 0 cannot fall below a floor that grows with mm.

Micro-averaging. Micro-averaged precision, recall and F1F_{1} are all equal to accuracy on single-label data, so reporting the three together conveys one number. And for measures such as balanced accuracy or MCC, the pooled micro value can lie outside the range of the per-class values, so no choice of weights reproduces it from a macro average.

aggmetrics addresses both issues. It implements the construction of Prati (2027), in which micro-, macro-, exemplar- and fold-pooled averaging are four instances of one operation, and it records the properties of each measure that determine such behaviour, so they can be queried and checked.

© 2026 R. C. Prati.

C. PRATI