Testing the Test: Score-Direction Instability in Class-Split Anomaly Detection

Alejandro Ascárate, Leo Lebrat, Rodrigo Santa Cruz, Clinton Fookes, Olivier Salvado

TL;DR

This paper exposes a fundamental flaw in how we evaluate anomaly detection (AD) models: the popular "class-split" benchmark is often mathematically ill-posed. The authors introduce neighborhood class leakage, a simple diagnostic tool that predicts when these benchmarks will produce unstable or inverted results, proving that many AD "successes" are actually just artifacts of dataset geometry rather than robust detection ability.

What Problem Does This Paper Address?

In anomaly detection, we often lack "real" anomalies for testing. The standard workaround is the within-dataset class-split protocol: you take a labeled dataset (like CIFAR-10), treat nine classes as "normal," and hold out the tenth as the "anomaly."

The authors argue this protocol relies on a shaky assumption: that the semantic label "anomaly" corresponds to a distinct geometric separation in the model's representation space. In reality, many "anomalous" samples (e.g., a specific breed of dog) actually lie closer to the "normal" mixture (other animals) than many normal samples do to each other.

When this overlap occurs, the benchmark breaks. Anomaly scores might collapse toward chance (AUROC ≈ 0.5) or even invert (AUROC < 0.5), meaning the model thinks the anomalies are "more normal" than the normal data. Crucially, the "correct" direction of the score can flip depending on which class you hold out, making the benchmark a moving target that fails to measure a consistent notion of "anomalousness."

Methods

The authors propose a training-free diagnostic to catch this failure before it happens:

  1. Neighborhood Class Leakage ($L_k$): For every point in a dataset, they look at its $k$-nearest neighbors in a given representation space (like raw pixels or a VAE's latent space). The "leakage" is the fraction of neighbors that have a different class label. If $L_k$ is high, the classes are heavily mixed, and the benchmark is likely ill-posed.
  2. Instability Metrics: They formalize ways to measure benchmark failure:
  3. Inversion Rate ($\rho_{inv}$): How often the AUROC drops below 0.5.
  4. Direction Instability ($\rho_{dir}$): A metric that quantifies how much the "preferred" score direction (high vs. low) changes across different held-out anomaly classes.
  5. Experimental Matrix: They tested three scoring families (kNN, Isolation Forest, and Local Outlier Factor) across multiple datasets and representations to ensure the findings weren't just artifacts of one specific algorithm.

Datasets

The study uses three image datasets of increasing visual complexity:

  • Fashion-MNIST: Used as a "negative control" because its classes are relatively well-separated in pixel space.
  • CIFAR-10: A standard benchmark that shows significant class overlap.
  • Imagenette: A 10-class subset of ImageNet, representing high visual complexity and significant manifold overlap.

Key Insights and Ideas

  • Geometry Trumps Semantics: A model doesn't know a "truck" is an anomaly if the truck's pixels look just like the "cars" in the normal set. If the geometry doesn't align with the labels, the benchmark is testing the dataset's quirks, not the model's intelligence.
  • The "Flip" Fallacy: Researchers often "fix" an inverted AUROC by simply flipping the sign of the anomaly score. The authors argue this is wrong: if Class A requires a positive sign and Class B requires a negative sign to show "anomalousness," the model hasn't learned a general concept of an anomaly—it's just caught in a geometric ambiguity.
  • Latent Spaces Aren't a Magic Bullet: Interestingly, moving from raw pixels to VAE latent spaces didn't always solve the problem. In some cases (like Imagenette), the latent representation actually increased class leakage, making the benchmark even more unstable.

Key Results

  • Leakage Predicts Failure: In Fashion-MNIST (low leakage, $L_k \approx 0.24$), AUROC scores were stable. In CIFAR-10 and Imagenette (high leakage, $L_k > 0.75$), the benchmarks exhibited massive instability.
  • Widespread Inversion: For CIFAR-10 in pixel space, the inversion rate was roughly 43%. This means nearly half of the possible "anomaly" choices resulted in the model ranking anomalies as "more normal" than the training data.
  • Directional Chaos: The direction-instability rate ($\rho_{dir}$) reached as high as 0.63 for Imagenette. This confirms that there is no single "correct" way to score anomalies in these datasets; the definition of an anomaly changes entirely depending on which class is held out.

Limitations and Future Work

  • Diagnostic, Not Cure: The proposed leakage index tells you if a benchmark is broken, but it doesn't provide a way to fix the representation to better align with semantic categories.
  • Representation Dependency: The leakage index is specific to the chosen representation (e.g., pixels vs. a specific VAE). A "bad" benchmark in one space might be "good" in another, but the paper doesn't explore how to automatically find those "good" spaces.
  • Future Directions: The authors suggest that AD researchers should report leakage and instability diagnostics as standard practice to prove their results aren't just exploiting dataset-specific geometric quirks.

Summary updated

BibTeX
@inproceedings{ascarate2026testing,
  author = {Alejandro Ascárate and Leo Lebrat and Rodrigo Santa Cruz and Clinton Fookes and Olivier Salvado},
  title = {{Testing the Test: Score-Direction Instability in Class-Split Anomaly Detection}},
  booktitle = {Hypothesis Testing @ ICML},
  year = {2026},
  url = {https://openreview.net/forum?id=PI6TU1L5cZ},
}

Loading related content...

Figure