# Improved Anomaly Detection by Using the Attention-Based Isolation Forest
## 5 Numerical Experiments
### Real Datasets
It is interesting to study how the hyperparameter \(\tau\) impacts the performance of ABIForest and iForest. The corresponding dependencies are depicted in Figures 11-13. The results of comparisons were obtained under the conditions of the optimal values of \(\epsilon\) and \(\omega\) given in Table 7. One can see in Figure 11 that \(\tau\) differently impacted the performance of ABIForest and iForest for the Credit dataset, whereas the corresponding dependencies scarcely differed for the Ionosphere dataset. This peculiarity was caused by the optimal values of the contamination parameter \(\epsilon\). It can be seen from Table 7 that \(\tau_{opt}=0\) for the Ionosphere dataset. This implies that the attention weights were determined only by the softmax operations, which weakly impacted the model performance, and their values were close to \(1/T\). Moreover, the Ionosphere dataset was one of the smallest datasets, with a large number of anomalous instances (see Table 1). Therefore, additional learnable parameters may lead to overfitting. This is a reason for why the optimal hyperparameter \(\epsilon\) did not impact the model performance. It is also interesting to note that the optimal value of the contamination parameter for the Mullcross dataset was 0 (see Table 7). However, one can see quite different dependencies in the right panel of Figure 12. This was caused by the large impact of the softmax operations, whose values were far from \(1/T\), and they provided results that were different from those of iForest. Generally, one can see in Figures 11-13 that the models strongly depended on the hyperparameters \(\tau\) and \(\epsilon\). Most of the dependencies illustrated that there was an optimal value of \(\tau\) for each case that was close to 0.5 for iForest and for ABIForest. The same can be said about the contamination parameter \(\epsilon\). In order to study how ABIForest performed in comparison with iForest by changing the number of instances, we considered the Ionosphere dataset. Table 8 shows the F1-score measures obtained by iForest and ABIForest for different numbers of instances that were randomly selected from the dataset under the condition that the ratio of normal and anomalous instances was not changed. It can be seen from Table 8 that ABIForest provided better results in comparison with those of iForest. Moreover, the difference between the F1-score measures increased as \(n\) decreased. It is also interesting to note that iForest outperformed ABIForest by \(n=80\). This can be explained by the overfitting of ABIForest due to the training parameters (vector **w**). Another question is that of how the number of anomalous instances impacts the performance of ABIForest under the condition that the number of normal instances is not changed. The corresponding numerical results are shown in Table 9. It is important to point out that ABIForest outperformed iForest for all numbers of anomalous instances. Moreover, the difference between the F1-score measures for ABIForest and iForest increased as \(n_{anom}\) decreased. Figure 12: Comparison of iForest and ABIForest with different thresholds \(\tau\) and with different contamination parameters \(\epsilon\) for the Arrhythmia (the **left** panel) and Mullcross (the **right** panel) datasets. Figure 13: Comparison of iForest and ABIForest with different thresholds \(\tau\) and with different contamination parameters \(\epsilon\) for the Http (the **left** panel) and Pima (the **right** panel) datasets.