Probabilistic Extension of Precision, Recall, and F1 Score for More Thorough Evaluation of Classification Models (2020)

Abstract: In pursuit of the perfect supervised NLP classifier, razor thin margins and low-resource test sets can make modeling decisions difficult. Popular metrics such as Accuracy, Precision, and Recall are often insufficient as they fail to give a complete picture of the model’s behavior. We present a probabilistic extension of Precision, Recall, and F1 score, which we refer to as confidence-Precision (cPrecision), confidence-Recall (cRecall), and confidence-F1 (cF1) respectively. The proposed metrics address some of the challenges faced when evaluating large-scale NLP systems, specifically when the model’s confidence score assignments have an impact on the system’s behavior. We describe four key benefits of our proposed metrics as compared to their threshold-based counterparts. Two of these benefits, which we refer to as robustness to missing values and sensitivity to model confidence score assignments are self-evident from the metrics’ definitions; the remaining benefits, generalization, and functional consistency are demonstrated empirically.

## introduction supervised machine learning classifiers are typically trained to minimize error. this error is evaluated using one or multiple metrics, the choice of which has been a continuous debate in research and industry for multiple decades @xcite . many criteria need to be considered when choosing a metric, including but not limited to: interpretability, computational cost, differentiability, and popularity in a specific field. as an example, a typical workflow of model development is to use a loss function such as cross-entropy or hinge loss during training for weight optimization, then use an easily interpretable metric such as accuracy, precision, or recall when testing the model against a holdout sample of examples. this is because the mentioned loss functions are differentiable convex functions, enabling optimization algorithms such as gradient descent to find minima with reasonable computational cost. in contrast, the test-set evaluation metrics are often required to be easy to relate to the real-world problem the classifier is designed to help solve, in order to give a concrete idea of performance or success to the stakeholders. essentially, all the criteria mentioned serve the same underlying purpose of driving modeling decisions. the heterogeneous nature of model evaluation illustrates how there could be no universal criteria for driving model decisions, or so-called "best metric", as each criterion could be advantageous under specific operating conditions @xcite , or even preferred by stakeholders for reasons that do not need to be scientifically driven (such as interpretability and business purposes). in the natural language processing (nlp) industry, new challenges have risen in the past few years in terms of performance evaluation, due to the complexity and scalable design of modern nlp systems such as those powering google assistant, amazon alexa, or apple's siri @xcite . such systems are built to support devices with a potentially limitless number of functionalities, as reflected by the alexa skill developer toolkit and google actions, allowing external developers to add additional functionality to the nlp system, supporting new phrases and therefore increasing the number of choices the system needs to disambiguate between. this sharp rise in scale and complexity has made the most commonly used metrics (accuracy, precision, recall, f1 score) insufficient in depicting a comprehensive picture of the impact introduced by changes in these systems. a key reason behind this gap is that classification models typically output an n-best list of model predictions, each associated with a confidence score (or probability score), and while simple systems (and most academic use-cases) only consider the highest-score prediction, more elaborate systems tend to leverage further information from the n-best to drive decisions. metrics such as accuracy, precision and recall simply compare the highest-score prediction with the test reference, ignoring the rest of the n-best output, while this ignored information often does impact the behavior of the nlp system. we provide 2 cases that exemplify the case of an nlp system being impacted by changes in the n-best output which are ignored by popular metrics: many evaluation metrics capable of measuring changes in confidence score assignments already exist. in this document we will use the taxonomy introduced by @xcite , classifying metrics into 3 categories: among these categories, probabilistic metrics have the potential to fill the evaluation gaps we described. in this paper we are proposing a probabilistic extension of threshold-based metrics. the goal is to introduce advantages of probabilistic metrics while retaining the relatability of thresholdbased metrics to the real-world operating cost function of the models, allowing for decision making that is both scientifically reliable and tied to the stakeholder's interests. we describe in section 3 why other probabilistic metrics are not sufficient to fill the evaluation gaps we are addressing with the newly proposed metrics. one of the primary benefits of probabilistic metrics is their ability to function more consistently in test-data sparse scenarios. it was demonstrated empirically by @xcite and @xcite that probabilistic metrics are more reliable in discriminating between models, since they leverage the most information from the model's output. this does not necessarily make them better metrics, as we stated earlier how modeling decisions are closely tied to operating conditions, but allows them to be more data-efficient (require less data to reach statistically significant results). recent developments in transfer learning @xcite demonstrated impressive ability to learn from small training sets (often referred to as few-shot learning), showing a wide nlp community interest in improving data-efficiency during model training, but we have not found any publication related to data-efficient model testing. usually the lack of training data would also imply a lack of test data, as they would be caused by the same underlying factor (expensive data collection and/or labelling, low-resource language), which highlights the value in developing ways to compare models with minimal test data requirements. as part of our investigation in this subject, we empirically show that our proposed metrics are more data efficient than their threshold-based counterparts, as they allow for modeling decisions with smaller test-sets. on a side note, some of the cases in which model confidence assignments are used in production require the scores to be probabilistically calibrated, as they are interpreted by the users as probabilities of events happening (e.g. disease prevention, weather forecasts). probabilistic calibration refers to the reliability of the scores in reflecting the true probability of the predictions being correct (e.g. if a calibrated model predicted in n cases that event x will happen with probability p, then event x should happen in approximately p*n of those cases). the proposed metrics do not evaluate for probabilistic calibration. for such use-cases we suggest the combined usage of a probability calibration measure (e.g. the expected calibration error @xcite , the reliability component of brierscore @xcite ) along with the proposed metrics, for a thorough evaluation of both performance and calibration. in this document, we describe four benefits of the proposed metrics. in comparison with their threshold-based counterparts, our metrics: a. have an equal or lower likelihood of being nan (robustness to nan values). ## related work in the publication employ decision values for soft-classifier evaluation with crispy references, @xcite have come to a similar formulation of probabilistic confusion matrix in the pursuit of a different goal. zhu considered the use-case of soft-classification, where "the classifier outputs not only a crispy prediction about its class label, but decision values which indicate to what extent does it belong to the all the classes as well", while we're considering hard classification, where the hypothesis probabilities output by the classifier indicate a confidence score that the hypothesis is correct, rather than a measure of class membership. from the resulting confusion matrix, zhu also formulated and empirically experimented with a probabilistic version of precision and recall, but only for binary classification. in our paper we dive deeper into the properties and potential of these metrics in multiclass hard classification when the model hypothesis confidence scores are impactful to the use case, especially in large-scale nlp systems. many publications @xcite ; hossin m, 2015) have shed light on pitfalls of commonly used evaluation metrics, and introduced alternatives and best practices to avoid those pitfalls. however, the criticized metrics have maintained their status as the standard in most industries and in academia. @xcite and @xcite have proposed methodologies to evaluate metrics against each other. we decided however to approach this problem from a different perspective. we will only compare a metric to its proposed extended counterpart (e.g. f1 vs cf1), and will not claim our proposed metrics to be objectively better, but simply demonstrate advantages they introduce, and in which situations those advantages are useful. in many use-cases it might still be preferable to use the regular precision and recall. there are many existing metrics that leverage the model's probability assignments over classes. brier score @xcite is an example, and is widely accepted as a standard in probabilistic weather forecasting. it is a strictly proper scoring rule, meaning it is uniquely optimized by reporting probabilistically calibrated model predictions. using our earlier defined methodology, brier-score can be calculated as: however, brier-score is not appropriate for largescale nlp systems such as those described in section 1, for two main reasons. the first one is that the data distribution is often imbalanced, as basic commands such as "stop" or "play" are dominating as compared to more niche features such as "open halo on my xbox", while the importance of a class is not reflected in its distribution (e.g. calling for emergency). this shows that these use cases require class-based measures, rather than aggregated ones like brier-score. secondly, it is important to be able to evaluate each class independently to understand the class tradeoffs (false accepts and false rejections from/towards competing classes), as different stakeholders are responsible for different functionalities. additionally, brier-score can be difficult to interpret and explain to non-technical stakeholders, as compared to other common metrics such as precision and recall. the concerns presented in this paragraph also hold for other probabilistic metrics we found in literature, such as the probabilistic confusion entropy @xcite and metrics usually used as loss functions during training. another widely popular metric is the area under the receiver operating characteristic curve (auc), which is originally for binary classifiers, but has been generalized to handle multi-class @xcite . auc is taxonomized as a rank-based metric rather than a probabilistic metric, as it is only sensitive to changes in confidence scores when those changes cause a difference in the ranking of test samples. multiple extensions of auc have been proposed to allow it to better leverage probability score assignments, such as the pauc @xcite and soft-auc @xcite but these extensions were only defined and analyzed in the binary classification case, and were also questioned by @xcite through empirical experiments indicating that the variants fail to be more effective than the original auc. ## benefit a: robustness to nan values precision, recall, and f1-score have a denominator which in some cases can be equal to zero, making it impossible to calculate an estimate of the metric. in the case of recall, this denominator (tp + fn) would be equal to zero for any label that is not present in the test-set (no sample in the test-set is assigned this label as its ground truth). as recall and crecall have the same denominator, this situation would also cause crecall to be nan for those labels. precision would be nan for any label that is not hypothesized by the model when making predictions in the test-set. notably, cprecision does not fall victim to the same issue (except in the extreme case when the model never assigns any confidence to that label). this is due to the fact that cprecision considers that the model is making soft predictions (confidence score assignments) for all labels for each test sample. this quality makes cprecision more robust than precision. the number of nan values for precision increases as the test-set size goes smaller, which also affects f1, as a nan precision causes a nan f1. this makes cf1 less likely to have nan values than f1 under small test-set sizes. especially in imbalanced datasets or datasets with a large number of possible classes, this issue is burdensome as your test-set needs to be very large to have a high likelihood of all classes being hypothesized. ## benefit b: model confidence score sensitivity intuitively, it appears as a good characteristic for a model to be more confident when being correct and less confident when being wrong. even though in some use cases this might not result in better outcomes for the stakeholders since only the highestscore prediction is actually used in the final application. nonetheless, selecting a better model can yield benefits in the long term, or when noise/outof-sample data is introduced, as the score assignments reflect how well the model understands the underlying data. we did not deem it necessary to perform an empirical demonstration of this quality, as it is a central aspect in the definition of the proposed metrics. in order to concretely illustrate the practical use of benefit b in an nlp production environment, consider a case where a company is building a semiautomated text labelling pipeline, where a model automatically labels text samples when the top prediction's confidence score is higher than a chosen threshold (e.g. 0.99), and sends the remaining samples to humans for manual labelling (e.g. amazon sagemaker ground truth as an nlp pipeline). in cases where the label space is large (common in large-scale nlp) human annotators cannot be familiar with all annotations. to address this, the pipeline presents the human annotator with the model's n-best output predictions as suggestions, to improve efficiency and reduce their burden. evaluating this nlp model with threshold-based metrics would not be appropriate, as the full n-best output is used to influence the human annotator's decisions. metrics such as brier-score and log-loss would be a step forward, but would not allow for a balanced class-based evaluation, and would not give visibility over the tradeoffs between classes. the latter metrics are also difficult to interpret, as the stakeholders are likely to be interested in measures they can easily relate to, and a potential break-down of which labels are more difficult to identify. in such case, cprecision, crecall, and cf1 would be appropriate, as they would bring the thorough evaluation of probabilistic metrics combined with the interpretability and robustness to class imbalance of precision and recall. ## empirical results in our experiments we directly compare each of the 3 threshold-based metrics with their probabilistic counterpart. our goal is to support the claimed benefits of generalization and functional consistency. we present results on the snli dataset @xcite , a dataset of paired sentences (560152 training samples and 10000 test samples) rated by annotators as either "neutral", "entailment", or "contradiction" depending on how the sentences relate to each other. please note that as snli does not suffer from data imbalance and only has 3 classes, this experiment is not intended to illustrate all of the advantages of the proposed metrics in large-scale commercial nlp pipelines. instead, we simply use snli to experimentally support the generalization and functional consistency benefits. ## potential shortcomings to consider as mentioned in the introduction, the proposed metrics do not evaluate for probabilistic calibration. there are many cases in which model probability scores are used in production with the expectation of reflecting reliable probabilities. in such cases, probabilistic calibration would have to be evaluated separately using a strictly proper scoring rule @xcite . another aspect to consider is interpretability. the proposed extensions lack the degree of direct interpretability afforded by their threshold-based counterparts. we believe that they still have a high degree of interpretability when compared to other metrics such as brier score and cross-entropy. we believe that these downsides do not necessarily pose a problem as long as they are known to the users of the metrics, so they can take appropriate measures in cases when it is required. ## future work in this paper we only focused on classification, and not named entity recognition (ner), while nlp often requires both. many ner specific metrics like ser @xcite consider the possibility of having slot insertions or deletions, making them more appropriate for evaluating ner. in the future we hope to extend metrics like ser to gain these benefits. we also hope to investigate the feasibility of altering these proposed metrics to be strictly proper scoring rules @xcite allowing for a dual assessment of probabilistic calibration and performance. strict proper scoring will aid us as we plan to study the potential use of these metrics as a differentiable model loss for training. finally, we hope to soon address the question of how to deal with output quantization where discrete confidence bins (high, med, low) rather than the continuous values are used by downstream tasks or customers. ## conclusion we introduced probabilistic extensions of widely used threshold-based metrics, and four benefits they provide as compared to their original counterparts. these benefits motivate the use of our proposed metrics in real-world problems where data is scarce and/or where the model confidence score assignments over its predictions are leveraged in production. we hope these metrics will allow for more reliable modeling decision-making in such cases. we hope this research will pave the way for further investigation into the challenge of model evaluation with under-representative test-sets. figure 7: sep-cnn model architecture used for experimentation on the nlp dataset