Generation of Loss Functions from Matrix-Based Binary Classification Metrics
Abstract
Most evaluation metrics for binary classification are derived from the confusion matrix, which is inherently non-differentiable because it relies on discrete predictions. This limits their direct use as loss functions in gradient-based learning, creating a mismatch between training objectives and evaluation criteria. To that end, we offer a general-purpose approach, AnyLoss , that transforms any confusion-matrix-based metric into a differentiable loss function. AnyLoss employs a distinct approximation strategy to estimate a specific, targeted metric score for the prediction model. This is followed by a theoretical and practical analysis of the method, which involves conducting extensive experiments with neural network architectures ranging from simple to advanced across diverse data modalities, including tabular, image, and text. The experimental results demonstrate the generality of our new method, which can target any evaluation metrics derived from a confusion matrix, and highlight that it excels at handling imbalanced datasets.
Fields of Study & Subjects
Imbalanced Data Classification Techniques
Adversarial Robustness in Machine Learning
Topic Modeling
Publication details
- Journal / source
- ACM Transactions on Knowledge Discovery from Data
- Publisher
- Association for Computing Machinery (ACM)
- Volume
- 20
- Issue
- 5
- Pages
- 1–40
- Publication date
- 27 March 2026
- Language
- EN