# Back to the Metrics: Exploration of Distance Metrics in Anomaly Detection
## 1 Introduction
### Evaluation Metrics  
In this study, we use several key evaluation metrics to assess the performance of our proposed method, including I-AUROC [5, 6], P-AUROC [5, 6], and AUPRO [6, 43, 44]. * I-AUROC (instance-based AUROC): This metric measures the AUROC at the instance level, which is crucial for image anomaly detection. It calculates the AUROC value for each image or object, providing an evaluation of the model's performance on individual instances (detection performance). The formula is as follows: \[I-AUROC=\text{AUROC}(y_{i},\hat{y}_{i}),\] (1) where \(y_{i}\) is the true label of instance \(i\), and \(\hat{y}_{i}\) is the predicted probability for instance \(i\). This metric ranges from 0 to 1. A value closer to 1 indicates better detection performance by the model. A value close to 0.5 suggests that the model is ineffective, and its predictive performance can be considered equivalent to that of a random prediction model. * P-AUROC (pixel-based AUROC): This metric calculates the AUROC at the pixel level, which is essential for evaluating the performance of anomaly segmentation tasks. It considers the predictions and true labels of each pixel within the images. The formula is as follows: \[P-AUROC=\text{AUROC}(y_{j},\hat{y}_{j}),\] (2) where \(y_{j}\) is the true label of pixel \(j\), and \(\hat{y}_{j}\) is the predicted probability for pixel \(j\). This metric ranges from 0 to 1. A value closer to 1 indicates better segmentation performance by the model. A value close to 0.5 suggests that the model is ineffective, and its predictive performance can be considered equivalent to that of a random prediction model. Due to the special nature of anomaly detection tasks, where normal pixels vastly outnumber abnormal ones, the reference value of this metric for segmentation performance is relatively low. * PRO (per-region overlap): This metric evaluates the overlap between predicted anomaly regions and ground truth regions, specifically for anomaly segmentation. The formula is as follows: \[PRO(T,P)=\frac{1}{K}\sum_{k=1}^{K}\frac{|P\cap T_{k}|}{|T_{k}|},\] (3) where \(K\) is the number of ground truth anomaly regions, \(P\) is the set of predicted anomaly regions (multiple connected components), and \(T_{k}\) is the \(k\)-th ground truth anomaly region (a single connected component). \(|\cdot|\) denotes the number of pixels in a connected component. PRO considers the size and location of anomaly regions, making it useful for evaluating segmentation performance. * AUPRO (area under the PRO curve): This metric evaluates the performance of anomaly segmentation by calculating the area under the PRO curve. PRO measures the overlap between predicted and ground truth anomaly regions. The formula is as follows: \[AUPRO=\int_{0}^{1}PRO(T,\mathbb{I}(\hat{y}_{s}>\mathcal{T}))\,d\text{FPR}\] (4) where \(T\) is the true segmentation label (pixel-level) of a image (a binary matrix, the set of connected pixels with a value of 1 represents a connected component), \(\hat{y}_{s}\) is the set of predicted anomaly scores for each pixel in the image, FPR represents the false positive rate at different thresholds \(\mathcal{T}\), and \(PRO(T,\mathbb{I}(\hat{y}_{s}>\mathcal{T}))\) is the PRO score at the corresponding threshold \(\mathcal{T}\). \(\mathcal{T}\) is initialized to the minimum prediction score that makes FPR 0, and as \(\mathcal{T}\) decreases, FPR exhibits a discrete upward trend, with the actual integral computed through numerical integration methods. This metric ranges from 0 to 1. A value closer to 1 indicates better segmentation performance by the model. A value close to 0.5 suggests that the model is ineffective, and its predictive performance can be considered equivalent to that of a random prediction model. AUPRO is similar to AUROC but is specifically designed for anomaly segmentation tasks, summarizing the model's performance across different thresholds. In the field of industrial anomaly detection, our work primarily focuses on the I-AUROC as the key performance metric, with AUPRO as the secondary metric.