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.
翻译:大多数异常检测系统输出的是分数而非校准后的决策,导致从业者需凭经验选择阈值且缺乏清晰的统计解释。符合推断异常检测通过将异常分数转化为在数据可交换性统计假设下有效的校准p值,解决了这一局限,同时有越来越多的文献将该思想扩展到该假设之外。本文介绍'nonconform'——一个用于在现有机器学习工作流中应用符合推断异常检测的Python包,并以此作为面向实现的学科导论基础。该包可与'scikit-learn'、'pyod'及自定义异常检测器集成,并提供统一的校准、p值生成与错误发现率控制接口。它支持多种符合化策略,从简单的分割符合校准到更节省数据且适应偏移的扩展方法。通过从基础概念到高级符合化策略的递进式阐述(辅以代码示例),本文建立起符合推断异常检测背后的统计思想与'nonconform'实际应用之间的桥梁。实证结果表明,所实现的方法能实现具有统计原则性的异常检测。该包及本文旨在使核心的符合推断异常检测工作流在实验及生产导向场景中更易访问且更具可重复性。