Standard conformal anomaly detection provides marginal finite-sample guarantees under the assumption of exchangeability . However, real-world data often exhibit distribution shifts, necessitating a weighted conformal approach to adapt to local non-stationarity. We show that this adaptation induces a critical trade-off between the minimum attainable p-value and its stability. As importance weights localize to relevant calibration instances, the effective sample size decreases. This can render standard conformal p-values overly conservative for effective error control, while the smoothing technique used to mitigate this issue introduces conditional variance, potentially masking anomalies. We propose a continuous inference relaxation that resolves this dilemma by decoupling local adaptation from tail resolution via continuous weighted kernel density estimation. While relaxing finite-sample exactness to asymptotic validity, our method eliminates Monte Carlo variability and recovers the statistical power lost to discretization. Empirical evaluations confirm that our approach not only restores detection capabilities where discrete baselines yield zero discoveries, but outperforms standard methods in statistical power while maintaining valid marginal error control in practice.
Figures & tables
Figure 1: The Resolution–Variance Dilemma. Under distribution shift, high importance weights create large steps in the conservative estimator, imposing a resolution floor of minimum attainable p -values that prevents rejection even for extreme scores. Standard randomization resolves the floor but introduces variance inflation via noise that can mask the signal. The proposed Weighted KDE decouples resolution from sample size, enabling rejection below the floor without stochastic noise.
Dataset
Method
Deterministic
Randomized
ntrain
ntest
Homogeneous
FDR
Power
FDR
Power
WBC
EDF
0.000±0.000
0.000±0.000
0.062±0.129
0.200±0.332
106
56
Weighted EDF
0.000±0.000
0.000±0.000
0.075±0.245
0.100±0.244
KDE
0.095±0.152
0.500±0.351
—
Weighted KDE
0.078±0.142
0.417±0.373
—
Ionosphere
EDF
0.000±0.000
0.000±0.000
0.076±0.199
0.150±0.221
112
88
Table 1: Performance of conformal inference strategies across anomaly detection benchmarks. All weighted methods employ WCS with homogeneous pruning to guarantee finite-sample FDR control. Values represent the mean ± standard deviation of the empirical marginal FDR and statistical power aggregated over 20 independent trials with randomized splits. We compare deterministic and randomized baselines against the proposed continuous (KDE-based) approach. The calibration and test set sizes are denoted by ntrain and ntest . Underlined values indicate validity violations (see Section 7.3 ).
Figure 2: Statistical power of weighted and randomized conformal methods with WCS pruning strategies, including the weighted KDE-based approach. Labels refer to the WCS pruning method. Results for Musk are omitted due to ceiling performance across all strategies. Error bars denote mean ± standard error over 20 randomized trials.
Appendix figures & tables4 assets
Supplementary material from the paper’s appendix.
Appendix
Dataset
Model
PR-AUC (mean ± std)
ROC-AUC (mean ± std)
Brier (mean ± std)
Wins
WBC
IForest
0.987 ± 0.009
0.993 ± 0.004
0.051 ± 0.005
12/20
COPOD
0.984 ± 0.008
0.992 ± 0.004
0.048 ± 0.011
3/20
ECOD
0.984 ± 0.008
0.992 ± 0.004
0.049 ± 0.012
2/20
HBOS
0.972 ± 0.014
0.988 ± 0.006
0.050 ± 0.006
3/20
LODA
0.913 ± 0.029
0.962 ± 0.011
0.071 ± 0.009
0/20
INNE
0.908 ± 0.042
0.954 ± 0.019
0.219 ± 0.011
0/20
Appendix
Table 4: Per-dataset detector comparison (mean ± std over 20 seeds). Results are aggregated across independent trials with per-seed model selection. Wins counts how often (out of 20) a detector is selected for the dataset according to the lexicographic rule PR-AUC ↑ , ROC-AUC ↑ , Brier ↓ .
Dataset
Model
PR-AUC (mean ± std)
ROC-AUC (mean ± std)
Brier (mean ± std)
Wins
Vowels
INNE
0.594 ± 0.092
0.913 ± 0.028
0.176 ± 0.012
20/20
IForest
0.312 ± 0.087
0.783 ± 0.049
0.188 ± 0.013
0/20
LODA
0.243 ± 0.065
0.696 ± 0.057
0.204 ± 0.012
0/20
HBOS
0.240 ± 0.076
0.701 ± 0.053
0.236 ± 0.015
0/20
ECOD
0.227 ± 0.070
0.628 ± 0.066
0.228 ± 0.017
0/20
COPOD
0.114 ± 0.028
0.526 ± 0.061
0.221 ± 0.010
0/20
Appendix
Table 5: Per-dataset detector comparison (mean ± std over 20 seeds). Results are aggregated across independent trials with per-seed model selection. Wins counts how often (out of 20) a detector is selected for the dataset according to the lexicographic rule PR-AUC ↑ , ROC-AUC ↑ , Brier ↓ .
Dataset
Method
Deterministic
Randomized
ntrain
ntest
Deterministic
FDR
Power
FDR
Power
WBC
EDF
0.000±0.000
0.000±0.000
0.062±0.129
0.200±0.332
106
56
Weighted EDF
0.000±0.000
0.000±0.000
0.050±0.224
0.017±0.074
KDE
0.095±0.152
0.500±0.351
—
Weighted KDE
0.078±0.142
0.417±0.373
—
Ionosphere
EDF
0.000±0.000
0.000±0.000
0.076±0.199
0.150±0.221
112
88
Appendix
Table 6: Performance of conformal inference strategies across anomaly detection benchmarks. All weighted methods employ WCS with deterministic pruning to guarantee finite-sample FDR control. Values represent the mean ± standard deviation of the empirical marginal FDR and statistical power aggregated over 20 independent trials with randomized splits. We compare deterministic and randomized baselines against the proposed continuous (KDE-based) approach. The calibration and test set sizes are denoted by ntrain and ntest . Underlined values indicate validity violations (see Section 7.3 ).
Dataset
Method
Deterministic
Randomized
ntrain
ntest
Heterogeneous
FDR
Power
FDR
Power
WBC
EDF
0.000±0.000
0.000±0.000
0.062±0.129
0.200±0.332
106
56
Weighted EDF
0.000±0.000
0.000±0.000
0.075±0.245
0.083±0.183
KDE
0.095±0.152
0.500±0.351
—
Weighted KDE
0.078±0.142
0.417±0.373
—
Ionosphere
EDF
0.000±0.000
0.000±0.000
0.076±0.199
0.150±0.221
112
88
Appendix
Table 7: Performance of conformal inference strategies across anomaly detection benchmarks. All weighted methods employ WCS with heterogeneous pruning to guarantee finite-sample FDR control. Values represent the mean ± standard deviation of the empirical marginal FDR and statistical power aggregated over 20 independent trials with randomized splits. We compare deterministic and randomized baselines against the proposed continuous (KDE-based) approach. The calibration and test set sizes are denoted by ntrain and ntest . Underlined values indicate validity violations (see Section 7.3 ).
Most anomaly detection systems output scores rather than calibrated decisions, leaving practitioners to choose thresholds heuristically and without clear statistical interpretation. Conformal anomaly detection addresses this limitation by converting anomaly scores into calibrated p-values that are valid under the statistical assumption of data exchangeability, with a growing literature extending this idea beyond that setting. We present 'nonconform', a Python package for applying conformal anomaly detection within existing machine-learning workflows, and use it as the basis for an implementation-grounded introduction to the field. The package integrates with 'scikit-learn', 'pyod', and custom anomaly detectors, and provides a unified interface for calibration, p-value generation, and false discovery rate control. It supports several conformalization strategies, ranging from simple split-conformal calibration to more data-efficient and shift-aware extensions. Through a progression from foundational concepts to advanced conformalization strategies, complemented by code examples, the paper connects the statistical ideas behind conformal anomaly detection to their practical use in 'nonconform'. Empirical results demonstrate that the implemented methods enable statistically principled anomaly detection. Together, the package and exposition aim to make core conformal anomaly detection workflows more accessible and reproducible in experimental and production-oriented settings.
Oliver Hennhöfer, Maximilian Kirsch, Christine Preisach
Intelligent Systems Research Group, Karlsruhe University of Applied Sciences
Conformal prediction (CP) provides powerful, distribution-free prediction sets, but its guarantees rely on the exchangeability of training and test data, which is often violated in practice due to covariate shifts. While weighted conformal prediction (WCP) is designed to handle such shifts, it can suffer from significant undercoverage when the density ratio between the distributions is unbounded and/or must be learned. This is because of both overfitting in learning the density ratio, and high variance in estimating the nonconformity score threshold. To address this, we introduce clipped least-squares importance fitting (CLISF) as a reduced-variance method for density ratio estimation. Specifically, we show that density ratios learned using CLISF, when plugged into WCP, have bounded expected undercoverage. Furthermore, we show that the undercoverage can be corrected by running WCP with a slightly inflated coverage target; crucially, we are able to estimate the required level of inflation from the data. We provide the first theoretical guarantees for weight clipping in conformal inference, achieving dataset-conditional coverage with a sample complexity that does not blow up with the higher moments of the true density ratio -- a key limitation of prior work. We verify our results on real-world benchmarks and synthetic data.
James Wang, Surbhi Goel
Department of Computer and Information Science, University of Pennsylvania, Philadelphia, PA 19104, USA.
Modern applications of conformal inference to multiple testing problems, such as outlier detection and candidate selection, often involve selecting test samples whose conformal p-values fall below a threshold. The quality of such methods is often measured by the false discovery proportion (FDP), defined as the fraction of incorrect selections. Existing approaches typically control the expected value of the FDP, using methods such as the Benjamini-Hochberg procedure. This approach fails to provide high-probability bounds on the realized false discovery proportion and invalidates statistical guarantees if the rejection threshold is selected after inspecting the data. This paper establishes finite-sample, distribution-free upper bounds on the FDP that hold simultaneously over all possible rejection thresholds, enabling arbitrary post hoc selection of the threshold. Simultaneous validity is achieved by constructing a high-probability envelope for the empirical distribution function of null conformal p-values by sampling from their joint distribution. Furthermore, our framework allows practitioners to modulate the envelope's shape, thereby producing tight bounds in rejection regions of primary interest. We use this flexible approach to derive simultaneous FDP upper bounds for both outlier detection and conformal selection. We demonstrate through synthetic and real-data experiments that the resulting bounds are both valid and substantially less conservative than those derived from existing approaches.
Ziang Song, Ying Jin, Emmanuel J. Candès
Department of Statistics, Stanford University · Department of Statistics and Data Science, University of Pennsylvania · Department of Mathematics, Stanford University