Choose a metric¶
Every metric here is an internal criterion: it uses only the data, the detector scores, or several candidates' scores. None of them needs labels, and none of them is a substitute for labeled evaluation. Ma et al. (2023) found that no internal strategy reliably beats a well-configured default, so treat these values as evidence and check them across splits.
| Family | Functions | Input | Better | Assumption |
|---|---|---|---|---|
| Score clusters | score_cluster_metrics |
scores + split size | per index | good scores split into two separated groups |
| ASI / ASOI | asi_score, asoi_score |
features + scores + split size | higher | predicted anomalies separate in feature space |
| AutoUAD | relative_top_median_score, expected_anomaly_gap_score, normalized_pseudo_discrepancy_score |
one or two score vectors | higher | useful detectors create a distinct score tail |
| Laplacian Score | laplacian_score |
features + scores | lower | nearby samples have similar scores |
| IREOS | ireos_score, ireos_scores, ireos_significance |
features + outlier probabilities | higher | outliers are easy to separate from the rest |
| SIREOS | sireos_score |
features + non-negative scores | lower | outliers are dissimilar to the rest |
| EM / MV | excess_mass_*, mass_volume_* |
data and uniform-reference scores | EM higher, MV lower | good normality level sets have small volume |
| Consensus | model_centrality_scores, udr_scores, hits_scores, ens_scores |
model-by-sample score matrix | higher | good candidates agree with other good candidates |
| Stability | ranking_stability_score |
run-by-sample score matrix | higher | robust detectors keep their ranking across refits |
Two helpers support these metrics. unify_scores turns raw scores into
outlier probabilities (Kriegel et al., 2011), which IREOS expects and which
make signed scores usable for SIREOS. borda_scores and
robust_borda_scores combine several metrics into one model ranking
(Goswami et al., 2023).
Score clusters¶
score_cluster_metrics treats the scores as a one-dimensional dataset, labels
the top n_outliers as one cluster, and returns ten internal clustering
indices, as Nguyen et al. proposed and Ma et al. benchmarked:
| Index | Better | Definition on the split |
|---|---|---|
silhouette |
higher | scikit-learn silhouette |
calinski_harabasz |
higher | scikit-learn Calinski-Harabasz |
davies_bouldin |
lower | scikit-learn Davies-Bouldin |
xie_beni |
lower | SSW / (n * d(c_normal, c_anomaly)^2) |
r_squared |
higher | (SST - SSW) / SST |
rmsstd |
lower | sqrt(SSW / (n - 2)) |
hubert_gamma |
higher | mean of d(x_i, x_j) * d(c_i, c_j) over pairs |
i_index |
higher | (0.5 * E_1 / E_2 * d(c_normal, c_anomaly))^2 |
dunn |
higher | min inter-cluster distance / max diameter |
s_dbw |
lower | Halkidi and Vazirgiannis Scat + Dens_bw |
SCORE_CLUSTER_INDICES maps each name to its direction. In one dimension with
a fixed split size, xie_beni, r_squared, and calinski_harabasz rank
candidates identically. All indices can reward an arbitrary bimodal score
distribution.
ASI and ASOI¶
Both use the score-induced partition in feature space, so scale features
first. ASI implements Equation 3 of the paper. The paper mentions a
normalization to [0, 1] without defining it, so none is applied. The ASOI
separation term is scale-dependent.
AutoUAD¶
RTM and EAG are computed on one score vector. RTM is not invariant to score offsets, so compare it within one score convention. It divides by the median score and raises for a negative median, where a stronger tail would score lower; shift signed scores to be non-negative first. NPD compares scores on held-out data with scores on generated Gaussian samples. The package accepts both score vectors and does not generate or train anything.
Laplacian Score¶
The default uses the paper's 0/1 k-nearest-neighbor weights. Pass
kernel_width for heat-kernel weights. The score is invariant to score scale
and sign.
IREOS¶
IREOS trains a kernel logistic regression classifier for every candidate
outlier and kernel width, so it is expensive and uses quadratic memory. Pass
outlier probabilities, for example from unify_scores, not raw scores. Use
ireos_scores to compare candidates under one shared gamma_max. The paper's
clump-size heuristic is round(sqrt(0.05 * n_samples)).
ireos_significance adjusts the index for chance, (I - E[I]) / (1 - E[I]),
and reports a z-score and a permutation p-value against solutions that assign
the same probabilities to random samples. For max_clump_size=1 the null mean
and deviation are exact and permutations are cheap, but one separability curve
per sample is needed. For larger clumps every permutation costs one IREOS
evaluation.
SIREOS¶
SIREOS weights each sample by s_j / sum(s), so the oriented scores must be
non-negative. Map signed scores, such as scikit-learn decision_function
output, with unify_scores first. The kernel width defaults to the 1%
quantile of non-zero pairwise distances, as in the authors' code.
Excess-Mass and Mass-Volume¶
Both need detector scores on a uniform reference sample over a support of known volume. They become unreliable as Monte Carlo volume estimates degrade in high dimensions. Goix suggests averaging over random feature subsets of size 5 there, which requires refitting the detector and so stays with the caller.
Consensus¶
Consensus strategies need at least two candidates and compare rankings, not raw scores. If most candidates share a failure mode, agreement is not evidence of correctness.
model_centrality_scores(MC) is the mean similarity to all other models.n_peersgives the sampled MCS variant andn_neighborsthe K-nearest-neighbor centrality of Goswami et al.udr_scoresis the median similarity to models of the same group, for example other configurations of the same detector.hits_scoresreturns hub scores of a model-sample graph with edge weights1 / rank, so agreement on the top outliers counts most.ens_scoresis the similarity to a pseudo ground truth built by greedy selective ensembling.
Similarity can be Kendall's tau, Spearman's rho, or NDCG. The defaults follow each method's source.
Ranking stability¶
Ranking stability measures robustness, not accuracy. Each row must hold scores for the same samples from one refit, for example on a random subsample of the training data, as in Perini et al.
Combining metrics¶
borda_scores sums N - position points per metric. top_k gives partial
Borda. robust_borda_scores first drops the metrics whose empirical influence
on the consensus is largest, following Goswami et al.
Sources and verification¶
Each implementation is tested against the paper's formula and, where the authors published code, against a transcription of that code.
| Metric | Source | Verified against |
|---|---|---|
| Score clusters | Nguyen et al.; Ma et al. | UOMS ten_metrics_mat.py, scikit-learn, s_dbw (Halkidi) |
| ASI / ASOI | Mahmud, Farou, and Lendak | paper equations |
| AutoUAD | Dai and Fan, ICLR 2025 | Algorithm 1 |
| Laplacian Score | He, Cai, and Niyogi | dense matrix definition |
| IREOS | Marques et al. | author implementation |
| SIREOS | Marques et al. | author implementation |
| EM / MV | Goix | author implementation |
| MC, MCS, UDR, HITS, ENS | Ma et al.; Lin et al.; Duan et al.; Rayana and Akoglu | UOMS, Algorithm 1 |
| KNN centrality, Borda | Goswami et al., ICLR 2023 | paper definitions |
| Ranking stability | Perini et al. | author implementation |
| Score unification | Kriegel et al. | ELKI scaling classes |
Deliberate deviations from author code¶
- EM curve: the supremum also includes the whole support (
1 - t * V), which the paper's definition admits but Goix's code omits. When the curve never drops toem_min, the full level range is integrated; Goix drops the last level. - HITS: UOMS ranks scores in ascending order before taking
1 / rank, which puts the largest weights on the most normal samples. The paper definesr_ijas the position in the ranked list of outliers, so the top outlier gets weight 1 here. - MCS: the paper averages similarities over the sampled peers; the UOMS script reuses UDR's median.
- S_Dbw: the original Halkidi and Vazirgiannis definition with mean
centers, instead of the
s_dbwpackage defaults that UOMS used. - RMSSTD: the UOMS script scales by the data dimension; here
P = 1because the index is computed on one-dimensional scores. This does not change rankings within a dataset. - Ties: stability and consensus metrics give tied scores their average
rank; author code breaks ties by sort order.
ASI, ASOI, and the score-cluster indices put every score tied with the
n_outlierscutoff in the anomaly group, so the split never depends on row order. - IREOS duplicates: a candidate that duplicates another row of
Xcannot be separated at any kernel width. The automaticgamma_maxsearch skips it with a warning instead of growing the width without end.