Anomaly detection methods identify examples that do not follow the expected
behaviour, typically in an unsupervised fashion, by assigning real-valued
anomaly scores to the examples based on various heuristics. These scores need
to be transformed into actual predictions by thresholding, so that the
proportion of examples marked as anomalies equals the expected proportion of
anomalies, called contamination factor. Unfortunately, there are no good
methods for estimating the contamination factor itself. We address this need
from a Bayesian perspective, introducing a method for estimating the posterior
distribution of the contamination factor of a given unlabeled dataset. We
leverage on outputs of several anomaly detectors as a representation that
already captures the basic notion of anomalousness and estimate the
contamination using a specific mixture formulation. Empirically on 22 datasets,
we show that the estimated distribution is well-calibrated and that setting the
threshold using the posterior mean improves the anomaly detectors' performance
over several alternative methods. All code is publicly available for full
reproducibility