Theory and tests¶
The package implements the construction of
R. C. Prati, A unified algebraic framework for classification performance evaluation, Information Fusion 138 (2027), 104767. doi:10.1016/j.inffus.2026.104767
From the paper to the code¶
Section and result numbers are those of the published article.
Idea in the paper |
Paper |
Where it is in the package |
|---|---|---|
Indicator matrices and the four cell matrices |
Section 4 |
|
The operators \(\Sigma_1\), \(\Sigma_m\), \(\Sigma_n\); extending a binary measure; correspondence with |
Section 5 (5.2) |
|
Soft classifier outputs |
Section 6.1 |
thresholding and argmax in |
Soft ground truth and t-norms |
Section 6.2 |
|
Cost-sensitive and ordinal evaluation |
Sections 6.3, 6.4 |
|
Partial and missing labels via masking |
Section 6.5 |
|
The fold operator \(\Sigma_k\); pooled versus averaged evaluation |
Section 6.19 |
|
Aggregation-decomposable measures; micro equals denominator-weighted macro |
Definition 7, Proposition 1, Theorem 1 (7.1) |
|
Positive-unlabeled data: recall is unaffected by the labelling propensity, precision is biased |
Section 6 (positive-unlabeled learning) |
|
Micro equals unweighted macro if and only if the denominators are balanced |
Corollary 1 (7.1) |
|
The target-wise operator for several targets |
Section 6 (multi-output) |
|
Hierarchical classification as a cost matrix (the taxonomy distance is a choice) |
Section 6 (hierarchical) |
|
Micro-averaging escaping the per-class range |
Remark 1, Example 1 (7.1) |
|
Micro-precision, micro-recall and micro-\(F_1\) collapse to accuracy |
Theorem 2 (7.2) |
the |
Degrees of freedom, the (recall, specificity) basis, redundant suites |
Proposition 3, Remark 2 (7.2) |
|
The product t-norm is the unique marginally consistent one |
Definition 8, Theorem 3, Corollary 3 (7.3) |
|
Ordinal losses as cost matrices |
Theorem 4, Corollary 4 (7.3) |
|
Lower boundary correctness fails under one-hot encoding (floors) |
Proposition 5 (7.4) |
|
Skew-invariant binary measures |
Definition 11, Theorem 5 (7.5) |
|
Prior dependence of one-vs-rest rates |
Proposition 6 (7.6) |
|
The micro-macro gap as a normalised covariance |
Corollary 6 (7.7) |
|
Undefined denominators and the convention for them |
Section 7.8 |
the |
Bayes-optimal thresholds, ERM-consistency, degenerate optima |
Proposition 9 (7.9) |
|
Dominance relations |
Section 7.11 |
|
Recovery of structural properties from a formula |
the software, not the paper |
|
Tests that verify the results¶
Each result of the paper is an executable test, so a change that breaks a theorem breaks a test:
Test |
Result verified |
|---|---|
|
micro equals denominator-weighted macro, the 14 decomposable measures × 3 samples |
|
the identity has no extension beyond that class |
|
only the product t-norm preserves marginals |
|
micro-P = micro-R = micro-F1 = accuracy, single-label |
|
Bayes threshold \((\beta+\delta)/(\alpha+\beta+\gamma+\delta)\) |
|
attainable floors under one-hot encoding |
|
one-vs-rest skew behaviour |
|
the micro-macro gap identity |
|
ordinal losses as cost matrices |
|
inference recovers all analytic annotations |
python -m pytest tests/test_theory.py -v
The numbers in the test names are those of the published article.
The same results are formalised in Lean 4 with Mathlib in a separate project; see the paper for the correspondence.