Training datasets for unsupervised anomaly detection are often assumed to be anomaly-free, but in practice, they frequently contain malicious or anomalous contamination. This contamination severely degrades the dependability and security of downstream detection models. While some contamination-robust methods exist, they rarely generalize across different model architectures and typically rely on a priori knowledge of the contamination ratio\textemdash information that is rarely available in real-world security operations. In this paper, we propose a novel, self-contained preprocessing framework for anomaly detection that identifies and removes training set contamination without relying on known contamination ratios. Our approach performs a dynamic analysis of the cosine similarity between each data point and its reconstruction during the early training stages of an auto-encoder, mapping points into a dynamic space where anomalous regions naturally exhibit lower density. By executing ``hard cleaning''\textemdash removing all identified anomalous candidates from the training pool\textemdash we systematically improve data quality. Because this cleaning occurs at the data level, the security and reliability improvements generalize seamlessly across various downstream anomaly detection architectures. Evaluating our framework across 8 distinct models and 10 security-relevant datasets, our approach achieves up to 100% contamination reduction, yielding average improvements of 11.2% in F1 score and 7.3% in classification accuracy.
Figures & tables
Fig. 1 : Blue and red inliers and anomalies respectively. ( 1(a) ): original vs ( 1(b) ) dynamic space.
Fig. 2 : Bopeto’s architecture.
Data set
# samples
# attributes
untreated anomaly (%)
CICIOT
416985
41
45
CIFAR-10
6000
1024
90
CREDIT
234333
30
0.2
ECG
4998
140
58
IDS
430256
95
43
KITSUNE
210171
116
23
TABLE I : The characteristics of data sets.
Fig. 3 : Visualisation of training data sets.
Fig. 4 : A sample of the dynamic space. Blue points are inliers and red are anomalies. A t - SNE projection is used for visualization.
Fig. 5 : (Left) shows the level of contamination per round across 9 different contamination ratios for each dataset. (Middle) displays the reduction in contamination ratio following data cleaning. (Right) demonstrates that Bopeto not only removes contamination but also retains at least 90% of inliers.
Fig. 6 : Differences in F 1 scores between models trained on Bopeto data and those trained on the original data are shown. Positive values indicate better performance with Bopeto. For instance, if the F 1 scores are 0.7 (Bopeto) and 0.55 (original), then ΔF1 = +0.15. The first row reports detailed ΔF1 values for each contamination ratio (as in Figure 5 ), while the second row shows the distributions of ΔF1 scores across contamination ratios.
Fig. 7 : Differences between models trained on Bopeto data and the original data using ( 7(a) ) accuracy, ( 7(b) ) precision and ( 7(c) ) recall. Positive values indicate the superiority of Bopeto. First row represents detailed performance differences per ith contamination ratio and second row represents their distributions across contamination ratios.
CICIOT
CIFAR
CREDIT
ECG
IDS
KDD
KITSUNE
MNIST
MVTEC
VISA
AE
original
0.73 ± 0.00
0.74 ± 0.10
0.47 ± 0.00
0.90 ± 0.05
0.60 ± 0.16
0.93 ± 0.00
0.56 ± 0.00
0.80 ± 0.55
0.76 ± 0.40
0.75 ± 0.35
Bopeto
0.73 ± 0.00
0.79 ± 0.15
0.47 ± 0.00
0.92 ± 0.05
0.70 ± 0.09
0.93 ± 0.00
0.56 ± 0.00
0.82 ± 0.05
0.77 ± 0.25
0.75 ± 0.45
SVDD
original
0.61 ± 0.03
0.66 ± 0.13
0.66 ± 0.03
0.76 ± 0.09
0.50 ± 0.33
0.72 ± 0.14
0.60 ± 0.09
0.65 ± 0.20
0.66 ± 0.15
0.67 ± 0.12
Bopeto
0.64 ± 0.04
0.67 ± 0.14
0.67 ± 0.01
0.81 ± 0.09
0.68 ± 0.36
0.83 ± 0.10
0.68 ± 0.04
0.68 ± 0.20
0.66 ± 0.05
0.69 ± 0.20
IF
original
0.39 ± 0.08
0.15 ± 0.01
0.28 ± 0.27
0.01 ± 0.00
0.24 ± 0.36
0.58 ± 0.01
0.44 ± 0.05
0.42 ± 0.06
0.45 ± 0.09
0.48 ± 0.08
Bopeto
0.53 ± 0.04
0.08 ± 0.01
0.67 ± 0.27
0.02 ± 0.01
0.70 ± 0.24
0.56 ± 0.01
0.50 ± 0.06
0.53 ± 0.07
0.49 ± 0.05
0.55 ± 0.04
TABLE II : Different rows (except the last row) represent average F 1 -scores. Last row counts successful cases where Bopeto shows superiority for anomaly detection. Improvement ratio represents the ratio of contamination identified by Bopeto, e.g, if there are 1,000 malicious instances in the training data set and the model identifies 700 of them, the ratio would be 70%.
CICIOT
CIFAR
CREDIT
ECG
IDS
KDD
KITSUNE
MNIST
MVTEC
VISA
p-value
effect size
Differences of F 1 scores
AE
0.00
0.10
0.00
0.02
0.10
0.00
0.00
0.06
0.04
0.04
3.32 ×10−13
0.45
SVDD
0.03
0.22
0.01
0.05
0.18
0.11
0.08
0.20
0.16
0.10
4.21 ×10−11
0.49
IF
0.14
0.02
-0.07
0.39
0.01
0.46
-0.02
0.12
0.12
0.11
1.41 ×10−15
0.54
LOF
0.34
0.21
0.04
0.21
0.54
0.47
0.58
0.06
0.09
0.07
5.53 ×10−23
0.61
ALAD
-0.01
0.12
-0.01
0.10
0.27
0.04
0.01
0.04
0.10
0.03
1.41 ×10−23
0.55
TABLE III : Differences of F 1 scores and AUC of various unsupervised anomaly detectors on original and Bopeto data. Positive values indicate the positive impact of Bopeto on the underline baseline anomaly detection method. The last three methods are those relying on contamination ratio information. The last two columns are p-value and effect size between performances of methods on original and Bopeto data. Reduction of statistical contamination using density-based clustering and isolation forest for identification of anomalies on dynamic spaces. The threshold for the p-value is set at 0.01.
Fig. 8 : Differences in F 1 scores between AE or SVDD trained on Bopeto data using IAD and their counterparts trained on the original data. Positive values indicate the superiority of Bopeto. First row represents detailed Δ F 1 scores per ith contamination ratio (as defined in Figure 5 ) and second row represents distributions of Δ F 1 scores across contamination ratios.
Fig. 9 : 5 runs of Bopeto. Contamination reduction (first row) and false positive (second row).
Fig. 10 : Illustrations of where Bopeto fails: tn, tp, fn and fp denote true negative, true positive, false negative and false positive respectively. Anomaly is the positive class here.
AE Architecture
IF
LOF
OCSVM
AE
p=0.27,d=0.08
p=0.41,d=0.05
p=0.35,d=0.07
DUAD
p=0.18,d=0.12
p=0.64,d=0.03
p=0.22,d=0.10
DAGMM
p=0.53,d=0.04
p=0.89,d=0.01
p=0.31,d=0.09
TABLE IV : Statistical comparison (p-value at 1% threshold and effect size) between AE architectures and traditional AD methods applied on the dynamic space on F 1 scores.