Deep Positive-Unlabeled Anomaly Detection for Contaminated Unlabeled Data

Hiroshi Takahashi, Tomoharu Iwata, Atsutoshi Kumagai, Yuuki Yamanaka · Submission to ICLR 2026 · Rejected

TL;DR

Semi-supervised anomaly detectors typically assume that unlabeled training data is completely "normal," but real-world data collections are almost always contaminated with hidden anomalies. This paper introduces a deep positive-unlabeled (PU) anomaly detection framework that mathematically subtracts anomaly contamination from the unlabeled pool, outperforming existing semi-supervised detectors while retaining the ability to flag novel, unseen anomaly types.

What Problem Does This Paper Address?

In many real-world applications—from factory defect detection to medical imaging—labeling every anomaly is impossible, but domain experts can often flag a small set of known anomalies. Semi-supervised anomaly detection exploits this setup: it trains deep models to assign low anomaly scores to an unlabeled pool $\mathcal{U}$ and high anomaly scores to a labeled anomaly pool $\mathcal{A}$.

However, this paradigm relies on a fragile assumption: that the unlabeled pool contains only normal data.

In practice, $\mathcal{U}$ is frequently contaminated with unlabeled anomalies. When a model tries to force these contaminated samples to have low anomaly scores while simultaneously maximizing scores on labeled anomalies, training signals conflict, severely degrading detection accuracy.

Methods

The authors resolve this issue by bringing unbiased Positive-Unlabeled (PU) learning into deep anomaly detection.

  1. Decomposing the Mixture Distribution: The unlabeled data distribution $p_U$ is modeled as a mixture of the normal distribution $p_N$ and the seen anomaly distribution $p_A$: $$p_U(x) = (1 - \alpha) p_N(x) + \alpha p_A(x)$$ where $\alpha \in [0, 1]$ represents the anomaly contamination rate.

  2. Formulating an Unbiased Loss: Rather than treating all unlabeled data as normal, the expected loss over pure normal data can be recovered by rearranging the mixture equation: $$(1 - \alpha)\mathbb{E}_{p_N}[\ell(x, \text{normal})] = \mathbb{E}_{p_U}[\ell(x, \text{normal})] - \alpha \mathbb{E}_{p_A}[\ell(x, \text{normal})]$$ The model effectively "cancels out" the contamination in $\mathcal{U}$ using the labeled anomaly set $\mathcal{A}$.

  3. Preventing Negative Risk with Deep Nets: Because deep neural networks can overfit, the empirical risk term can accidentally drop below zero and diverge to negative infinity. To stabilize training, the authors enforce non-negativity using an absolute value formulation: $$\mathcal{L}_\text{Proposed}(\theta) = \alpha \mathcal{L}_A^+(\theta) + \left| \mathcal{L}_U^-(\theta) - \alpha \mathcal{L}_A^-(\theta) \right|$$

  4. Concrete Instantiations: The framework applies to any differentiable, non-negative anomaly objective. The authors implement two variants:

  5. PUAE: Based on reconstruction errors via Autoencoders and binary cross-entropy.

  6. PUSVDD: Based on Deep Support Vector Data Description (DeepSVDD), which minimizes feature distance to a center $c$ for normal data and pushes anomalies away.
       Unlabeled Data (U)           Labeled Anomalies (A)
      [ Normal + Anomalies ]           [ Seen Anomalies ]
                \                             /
                 \                           /
      [ Compute Loss on U ]   -   α * [ Compute Loss on A ]
                 \                         /
                  \                       /
             Approximate Loss on Pure Normal Data
                              +
             Maximize Loss on Labeled Anomalies
                              ↓
              Robust Detector (PUAE / PUSVDD)

Datasets

The authors evaluated their approach across nine benchmarks:

  • Standard Vision & Digits: MNIST, FashionMNIST, SVHN, CIFAR-10, and CIFAR-100 (superclasses partitioned into nature vs. human concepts).
  • Medical Imaging (MedMNIST v2): Path (colorectal histology), OCT (retinal coherence tomography), and Tissue (kidney cortex cells).
  • Industrial Inspection: MVTec AD (high-resolution $224 \times 224$ images across 15 real-world manufacturing categories, utilizing a ResNet-34 backbone).

In all setups, training data was contaminated (e.g., $10\%$ contamination, $\alpha=0.1$), and test splits included both seen and unseen anomaly types.

Key Insights and Ideas

  • Why not just use standard PU binary classification? Standard PU classifiers learn a sharp decision boundary between normal points and seen anomalies. Consequently, they fail completely on unseen or novel anomalies (zero-day attacks, new defect types). By contrast, PU anomaly detectors learn a compact boundary around normal data, preserving sensitivity to unexpected out-of-distribution patterns.
  • Soft weighting beats hard latent labels: Prior robust semi-supervised baselines (like LOE and SOEL) infer discrete latent labels for unlabeled samples. If misidentified, model performance degrades quickly. PUSVDD uses $\alpha$ only to weight continuous loss distributions, making it significantly more robust to errors in estimating $\alpha$.

Key Results

  • Consistent SOTA Performance: PUSVDD achieved the best or tied-for-best AUROC across all datasets, substantially outperforming previous state-of-the-art semi-supervised methods like SOEL and DeepSAD:
  • MNIST: 0.989 (PUSVDD) vs. 0.965 (SOEL) vs. 0.942 (DeepSAD).
  • CIFAR-10: 0.803 (PUSVDD) vs. 0.775 (SOEL) vs. 0.726 (DeepSAD).
  • Tissue: 0.731 (PUSVDD) vs. 0.703 (SOEL) vs. 0.683 (DeepSAD).
  • MVTec AD: 0.793 overall AUROC (PUSVDD) vs. 0.669 (SOEL).
  • Generalization to Unseen Anomalies: Standard PU classification degraded drastically on unseen anomalies (e.g., an AUROC of 0.452 on CIFAR-100 unseen), whereas PUSVDD scored 0.573 (and up to 0.925 on OCT unseen), confirming that the geometry of the deep anomaly detector protects against novel failure modes.

Limitations and Future Work

  • The "Seen Contamination" Assumption: The theoretical derivation assumes that the anomalies contaminating the unlabeled set $\mathcal{U}$ follow the exact same distribution as the labeled anomalies $\mathcal{A}$. If $\mathcal{U}$ is contaminated by entirely novel, unseen anomaly types during training, the statistical cancellation is no longer unbiased.
  • Contamination Rate Dependency: While more resilient to miscalibration than discrete query methods, setting $\alpha$ far from the true anomaly ratio still degrades detection performance.
  • Future Directions: Integrating sample-selection techniques (like LOE) directly into the PU risk formulation to provide theoretical guarantees when unseen anomaly types pollute the unlabeled training data.

Summary updated

Abstract

Semi-supervised anomaly detection has attracted attention, which aims to improve the anomaly detection performance by using a small amount of labeled anomaly data in addition to unlabeled data. Existing semi-supervised approaches assume that most unlabeled data are normal, and train anomaly detectors by minimizing the anomaly scores for the unlabeled data while maximizing those for the labeled anomaly data. However, in practice, the unlabeled data are often contaminated with anomalies. This weakens the effect of maximizing the anomaly scores for anomalies, and prevents us from improving the detection performance. To solve this, we propose the deep positive-unlabeled anomaly detection framework, which integrates positive-unlabeled learning with deep anomaly detection models such as autoencoders and deep support vector data descriptions. Our approach enables the approximation of anomaly scores for normal data using the unlabeled data and the labeled anomaly data. Therefore, without labeled normal data, our approach can train anomaly detectors by minimizing the anomaly scores for normal data while maximizing those for the labeled anomaly data. Our approach achieves better detection performance than existing approaches on various datasets.
BibTeX
@misc{takahashi2024deep,
  author = {Hiroshi Takahashi and Tomoharu Iwata and Atsutoshi Kumagai and Yuuki Yamanaka},
  title = {{Deep Positive-Unlabeled Anomaly Detection for Contaminated Unlabeled Data}},
  year = {2024},
  eprint = {2405.18929},
  archivePrefix = {arXiv},
  url = {https://arxiv.org/abs/2405.18929},
}
Figure