# Improved Anomaly Detection by Using the Attention-Based Isolation Forest
## 5 Numerical Experiments
### Synthetic Datasets
It can also be seen from the results in Figure 4 that the F1-score significantly depended on the hyperparameter \(\omega\), especially for small values of \(\epsilon\). The F1-score measures as functions of the contamination parameter \(\epsilon\) for different numbers of  
Figure 6 illustrates the results of a comparison between iForest and ABIForest on the basis of the test set, which is depicted in the left panel of Figure 6. The predictions obtained by iForest consisting of 150 trees with \(\tau=0.5\) are depicted in the central panel. The predictions obtained by ABIForest with \(\epsilon=0.5\), \(\tau=0.6\), and \(\omega=0.1\) are shown in the right panel. One can see in Figure 6 that some points in the central panel were incorrectly identified as anomalous ones, whereas ABIForest correctly classified them as normal instances. Figure 6 should not be considered as a single realization that defines the F1-score. It is one of many cases corresponding to different generations of test sets; therefore, the numbers of normal and anomalous instances can be different in each realization. Similar dependencies for the Normal dataset are shown in Figures 7 and 8. However, it follows from Figure 7 that the largest values of the F1-score were achieved for \(\epsilon=0\). This implies that the main contribution to the attention weights was caused by the softmax operation. The F1-score measures shown in Figure 8 were obtained with the hyperparameters \(\gamma=0.6\) and \(\omega=20\). Figure 5: F1-score measures as functions of the contamination parameter \(\epsilon\) for different numbers of trees in iForest \(T\) for the Circle dataset. Figure 6: Comparison of the test set generated for the Circle dataset (the **left** panel), predictions obtained by iForest (the **central** panel), and predictions obtained by ABIForest (the **right** panel). The results of a comparison between iForest and ABIForest for the Normal dataset are shown in Figure 9, where a realization of the test set and the predictions of iForest and ABIForest are shown in the left, central, and right panels, respectively. The predictions were obtained by means of iForest consisting of 150 trees with \(\tau=0.5\) and by ABIForest consisting of the same number of trees with \(\varepsilon=0.5\), \(\tau=0.6\), and \(\omega=0.1\). Figure 8: F1-score measures as functions of the contamination parameter \(\varepsilon\) for different numbers of trees in iForest \(T\) for the Circle dataset. Figure 7: F1-score measures as functions of the softmax hyperparameter \(\omega\) for different contamination parameters \(\varepsilon\) and for the Normal dataset. Another interesting question is that of how the prediction accuracy of ABIForest depends on the size of the training data. The corresponding results for the synthetic datasets are shown in Figure 10, where the solid and dashed lines correspond to the F1-scores of iForest and ABIForest, respectively. The numbers of trees in all experiments were taken as \(T=150\). The same results are also given in numerical form in Table 6. It can be seen in Figure 10 for the Circle dataset that the F1-score of iForest decreased with the increase in the number of training data after \(n=200\). This was because the number of trees (\(T=150\)) was fixed, and the trees could not be improved. This effect was discussed in [17], where the problems of swamping and masking were studied. The authors of [17] considered subsampling to overcome these problems. One can see in Figure 10 that ABIForest coped with this difficulty. Another behavior of ABIForest could be observed for the Normal dataset, which was characterized by two clusters of normal points. In this case, the F1-score decreased as \(n\) increased, and then increased with \(n\). Figure 10: Illustration how the F1-score measures of iForest and ABIForest depend on the number of training data for the Circle dataset (the **left** panel) and the Normal dataset (the **right** panel).