32 Anomaly Detection with Variational Autoencoders component: L(zγ)=(1−λ)LR(zγ)+λLD(zγ). (3.9) This loss function from Equation (3.9) can then also be used as an anomaly score, instead of a known model likelihoodpθ. Normal data should get a lower loss value since it is similar to the data the model was trained on, whereas we expect anomalous data to receive a higher loss value since the model wasn’t trained to generate such data. 3.3.3 Thresholds for Likelihood Scores After training a generative model, we can use it to obtain anomaly score values for our test set. The test set consists of previously unseen data, both normal and anomalous. A relatively small number of data points suffices here, as we only aim to find a linear separation between the anomaly scores for normal and anomalous data. The anomaly score is a measure of how anomalous a given data point is. In the case of VAEs, we use the negative ELBO as an anomaly score, which itself is an approximation of the negative log-likelihood (NLL) −logpθ(x). In other words, more likely images (according to the model) should have a lower anomaly score. For GANs, we use the loss from Equation (3.9) as an anomaly score, which should also assign lower scores to images that are more likely according to the model. We can visualise the distribution of these scores for the negative and positive class in a density plot, such as in Figure 3.1a. Classifying anomalies now becomes a matter of deciding a threshold on the anomaly scores; classifying all instances with a lower score as non-anomalous, and all with a higher score as anomalous. Optimally, a threshold should separate the normal from the anomalous samples by their anomaly scores. We can analyse the effect of different thresholds by means of an ROC curve, such as in Figure 3.1b. The area under the curve (AUC or auROC) provides a scoring system to evaluate the performance of the anomaly detection. Additionally, we use Precision-Recall Curves (PRC) such as in Figure 3.1c, as it has been argued that they are more informative in the context of imbalanced binary data (Saito and Rehmsmeier, 2015). The AUC for these curves (auPRC) provides an additional scoring system to supplement the auROC scores.
RkJQdWJsaXNoZXIy MjY0ODMw