# Metrics Related to Confusion Matrix as Tools for Conformity Assessment Decisions
## 2 Materials and Methods
### Metrics Associated to Confusion Matrix Written in Metrology Manner  
Unlike the standard expressions for metrics associated with confusion matrices used in machine learning [31], all observed metrics here have been written using expressions specified in Formulas (17)-(20). Accuracy is included in basic metrics that are used to evaluate the behavior of tested models. Originally, this metric details the ratio between the number of rings classified into the TP and TN categories in relation to the total number of rings. In risk assessment, always applies \(TP+TN+FA+FR=1\). That is why the accuracy metric in the conformity assessment procedure actually measures the total number of rings classified in the TP and TN categories and can be calculated as:  
\[\text{accuracy}=1-\text{R}_{\text{P}}-\text{R}_{\text{C}}. \tag{21}\]  
The precision metric gives the ratio of rings classified as TP in relation to the total number of rings within the acceptance interval. In risk terms, the precision can be written as:  
\[precision=\frac{p_{C}-R_{P}}{p_{C}-R_{P}+R_{C}}. \tag{22}\]  
The recall represents the ability of the model to detect all rings classified as TP within the set of rings conforming with the specification. This metric can be calculated as:  
\[recall=1-\frac{R_{P}}{p_{C}}. \tag{23}\]  
In unbalanced datasets, the goal is to increase the number of rings classified as TP without compromising precision. However, it is impossible to minimize precision and recall metrics simultaneously since they have inverse behaviors. When recall decreases, precision increases and vice versa [32]. For this reason, it is desirable to observe the F1 score, which considers both the precision and recall metrics. The F1 score metric is their harmonic mean and depends not only on the categories TP and TN but also on the categories FR and FA [33]. In this way, the bias of the model towards one of the classes is avoided. The F1 score is expressed as:  
\[F1=\frac{p_{C}-R_{P}}{p_{C}-R_{P}+\frac{R_{P}+R_{C}}{2}}. \tag{24}\]  
Among other significant metrics associated with confusion matrices, [PERSON]'s kappa statistics and [PERSON]'s correlation coefficient (MCC) have proven to be interesting for this paper. Both statistics provide an estimate of the level of agreement between real and predicted results [34]. In risk terms, [PERSON]'s kappa statistic can be calculated from:  
\[kappa=\frac{2[p_{C}(1-p_{C}-R_{C})-R_{P}(1-p_{C})]}{(1-p_{C})(p_{C}-R_{P}+R_{C })+p_{C}(1-p_{C}+R_{P}-R_{C})}. \tag{25}\]  
If the TP class is more important than the TN class, as it is in metrology, then the F1 statistic is more relevant than the MCC statistic [35]. On the other hand, MCC performs better on imbalanced data in relation to the accuracy and F1 score and results in a high score only if the prediction performed well for all four categories of the confusion matrix [36]. In metrological terms, [PERSON]'s correlation coefficient can be calculated as:  
\[MCC=\frac{[p_{C}(1-p_{C}-R_{C})-R_{P}(1-p_{C})]}{\sqrt{p_{C}(1-p_{C})(p_{C}-R _{P}+R_{C})(1-p_{C}+R_{P}-R_{C})}}\,. \tag{26}\]