# 新颖性检测

新颖性检测的任务，是在训练集不含异常类样本的前提下，对在某些方面不同于训练数据的测试样本进行分类。先建立一个描述“正常”数据的模型，每个测试样本得到一个新颖性分数 \( z(x) \)，与阈值 \( k \) 比较：若 \( z(x) < k \) 则称该样本正常，否则为异常。<sup>[1](https://www.robots.ox.ac.uk/~davidc/pubs/NDreview2014.pdf)</sup> 在软件文档中，这种设定被称为半监督异常检测，因为训练数据没有被离群点污染；相比之下，无监督离群点检测必须在已被污染的训练数据中找出异常。<sup>[2](https://scikit-learn.org/stable/modules/outlier_detection.html)</sup> 在大量文献中，异常检测和离群点检测被当作新颖性检测的同义词互换使用，名称不同，源于应用领域不同。<sup>[1](https://www.robots.ox.ac.uk/~davidc/pubs/NDreview2014.pdf)</sup>

| 事实 | 值 |
|---|---|
| 设定 | 训练数据只含正常（分布内）样本；测试样本对照“正常”模型打分 <sup>[1](https://www.robots.ox.ac.uk/~davidc/pubs/NDreview2014.pdf)</sup> |
| 输出 | 一个连续的新颖性分数 \( z(x) \)，在 \( k \) 处设阈值，而非类别概率；在 scikit-learn 中，内点标记为 1，离群点标记为 −1 <sup>[1](https://www.robots.ox.ac.uk/~davidc/pubs/NDreview2014.pdf)</sup>, <sup>[2](https://scikit-learn.org/stable/modules/outlier_detection.html)</sup> |
| 方法族 | 概率方法、距离方法、重构方法、域方法、信息论方法 <sup>[1](https://www.robots.ox.ac.uk/~davidc/pubs/NDreview2014.pdf)</sup> |
| 关键参数 | 单类 SVM 中的 \( \nu \) 直接控制可容忍的离群点比例 <sup>[3](https://dl.acm.org/doi/10.1162/089976601750264965)</sup> |
| 基于隔离的方法族 | 孤立森林仅靠隔离即可检测异常，通过子采样实现低线性时间复杂度 <sup>[4](https://doi.org/10.1145/2133360.2133363)</sup> |
| 标准指标 | ROC AUC，因为 TPR 和 FPR 对类别不平衡做了归一化 <sup>[5](https://link.springer.com/article/10.1007/s10618-023-00931-x)</sup> |
| 代表性基准 | 自监督表示学习加 OC-SVM 在五个图像基准上达到平均 AUC 89.9 <sup>[6](https://ar5iv.labs.arxiv.org/html/2011.02578)</sup> |

## 工作原理

2014年的一篇综述将新颖性检测技术分为五类：概率方法、距离方法、重构方法、域方法和信息论方法。<sup>[1](https://www.robots.ox.ac.uk/~davidc/pubs/NDreview2014.pdf)</sup>

**概率方法**估计正常数据上的密度 \( p(x) \)，并将低于阈值的样本标记为异常；对概率密度设阈值并没有直接的概率解释，这是该方法族的一个已知缺陷。<sup>[1](https://www.robots.ox.ac.uk/~davidc/pubs/NDreview2014.pdf)</sup> **域方法（边界方法）** 在数据周围画出边界。单类 SVM 估计一个函数 \( f \)，该函数在底层分布的支撑集上为正，在其他地方为负；其解是一个核展开 \( f(x) = \sum_{i} \alpha_{i} k(x_{i}, x) \)，在核所定义的特征空间中呈线性，系数通过二次规划求得。<sup>[3](https://dl.acm.org/doi/10.1162/089976601750264965)</sup> \( \nu \) 技巧引入了对离群点的软化处理，并直接控制离群点比例：当 \( \nu \) 趋近于 0 时，算法趋近于将所有数据与原点硬间隔分离；当 \( \nu \) 趋近于 1 时，决策函数对应于带阈值的 Parzen 窗估计器。<sup>[3](https://dl.acm.org/doi/10.1162/089976601750264965)</sup> [支持向量数据描述](https://www.edgepedia.org/zh/support-vector-data-description)（SVDD）则围绕对象构建球形决策边界，由球面上的支持向量描述。<sup>[7](https://rduin.nl/papers/prl_99_svdd.pdf)</sup>

**隔离方法**完全不需要密度或距离：孤立森林仅通过随机切分隔离一个点的难易程度来检测异常，通过子采样实现低线性时间复杂度。<sup>[4](https://doi.org/10.1145/2133360.2133363)</sup> **重构方法**在没有异常样本的数据上训练自编码器，因此新颖样本在推理时会产生更高的重构误差；像素级差异通过均方误差、残差误差、结构相似性（SSIM）或特征一致性来计算。<sup>[8](https://pure.uva.nl/ws/files/139262176/Improving_novelty_detection_using_the_reconstructions_of_nearest_neighbours.pdf)</sup>

## 实施方法

已发表的工作流程描述了三个组成部分：非异常数据分布的模型、样本对该分布的拟合度量，以及对该度量设阈值的决策规则。<sup>[8](https://pure.uva.nl/ws/files/139262176/Improving_novelty_detection_using_the_reconstructions_of_nearest_neighbours.pdf)</sup>

1. **在分布内数据上拟合。** 一个典型的 scikit-learn 示例在训练数据上拟合 `svm.OneClassSVM(nu=0.1, kernel="rbf", gamma=0.1)`，然后对训练集、常规新颖集和异常新颖集应用 `predict`，报告各集上的错误计数。<sup>[9](https://scikit-learn.org/stable/auto_examples/svm/plot_oneclass.html)</sup>
2. **对测试样本打分。** 内点标记为 1，离群点标记为 −1；`predict` 对通过 `score_samples` 获得的原始评分函数设阈值，阈值由 `contamination` 参数控制，`decision_function` 对离群点返回负值。<sup>[2](https://scikit-learn.org/stable/modules/outlier_detection.html)</sup> 对于新颖性模式下的局部离群因子，`predict`、`decision_function` 和 `score_samples` 只能用于新的未见数据，不能用于训练样本，否则结果会出错。<sup>[2](https://scikit-learn.org/stable/modules/outlier_detection.html)</sup>
3. **在没有离群点样本的情况下选择模型。** 使用三种方法：扰动法（扰动数据集）、均匀对象法（在数据周围生成人工对象）和 SDS，用交叉验证估计内点误差。<sup>[5](https://link.springer.com/article/10.1007/s10618-023-00931-x)</sup>
4. **验证。** ROC 曲线表示检测率与误报率之间的权衡。<sup>[1](https://www.robots.ox.ac.uk/~davidc/pubs/NDreview2014.pdf)</sup>

## 起源

该术语有文献记载的历史：一篇单类分类综述记录了 1975 年早期对“单类分类”的使用，“单类分类”一词起源于 1993 年，“新颖性检测”起源于 1994 年，以及离群点检测和概念学习等相关术语。<sup>[10](https://www.cambridge.org/core/journals/knowledge-engineering-review/article/oneclass-classification-taxonomy-of-study-and-review-of-techniques/EEDBC97CFD54B2B65BEB5FCD71593782)</sup> 一种早期统计方法逐步扩展[高斯混合模型](https://www.edgepedia.org/zh/gaussian-mixture-model)来表示“正常”系统状态，并用网络生长过程中使用的同一阈值筛选此前未见的数据，在一个包含 3644 个十维向量的脑电图数据库上演示了癫痫发作检测；它促使人们采用半参数混合模型来替代计算昂贵的 Parzen 窗。<sup>[11](https://www.robots.ox.ac.uk/~sjrob/Pubs/robertsTarassenko_RAN_1994.pdf)</sup>

单类 SVM 由[伯恩哈德·舍尔科普夫](https://www.edgepedia.org/zh/bernhard-scholkopf)（Bernhard Schölkopf）及其同事于 1999 年提出，其灵感来自早期工作，即用超平面将无标签数据与原点分离来刻画数据，并用核技巧和 \( \nu \) 技巧修正了该思想的两个缺陷：线性性和不处理离群点；期刊版本《估计高维分布的支撑集》于 2001 年发表在《神经计算》上。<sup>[3](https://dl.acm.org/doi/10.1162/089976601750264965)</sup> 塔克斯（Tax）和杜因（Duin）于 1999 年在《模式识别快报》上提出了支持向量域描述，受瓦普尼克（Vapnik）支持向量机的启发。<sup>[7](https://rduin.nl/papers/prl_99_svdd.pdf)</sup> 孤立森林由刘飞托尼（Fei Tony Liu）、丁凯明（Kai Ming Ting）和周志华（Zhi-Hua Zhou）于 2012 年发表在《ACM数据知识发现汇刊》上，是 2008 年 ICDM 论文的扩展版。<sup>[4](https://doi.org/10.1145/2133360.2133363)</sup> 扩展孤立森林由萨汉德·哈里里（Sahand Hariri）、马蒂亚斯·卡拉斯科·金德（Matias Carrasco Kind）和罗伯特·J·布伦纳（Robert J. Brunner）于 2019 年发表在《IEEE知识与数据工程汇刊》上。<sup>[12](https://doi.org/10.1109/tkde.2019.2947676)</sup>

## 变体

命名的变体横跨各方法族。深度 SVDD 被作者描述为一种用于无监督异常检测的完全深度单类分类目标；其超参数 \( \nu \in (0,1] \) 是离群点比例的上界，模型完全由网络参数和半径刻画，因此预测时无需存储训练数据。<sup>[13](https://proceedings.mlr.press/v80/ruff18a/ruff18a.pdf)</sup> SS-DSVDD 通过添加合页损失项将其推广到半监督设定，要求有标签的正常样本位于超球内，有标签的异常样本位于超球外。<sup>[14](http://www.gatsby.ucl.ac.uk/~balaji/udl2019/accepted-papers/UDL2019-paper-15.pdf)</sup> 在医学成像领域，f-AnoGAN 由托马斯·施莱格尔（Thomas Schlegl）及其同事于 2019 年在《医学图像分析》上提出，利用生成对抗网络提供快速无监督异常检测。<sup>[15](https://doi.org/10.1016/j.media.2019.01.010)</sup> 最近潜在[邻居](https://www.edgepedia.org/zh/neighbours)（NLN）算法由迈克尔·梅萨西克（Michael Mesarcik）及其同事于 2022 年在《阵列》上提出，同时对样本在自编码器潜在空间中相对其最近邻居的重构误差以及到这些邻居的平均潜在距离进行打分。<sup>[8](https://pure.uva.nl/ws/files/139262176/Improving_novelty_detection_using_the_reconstructions_of_nearest_neighbours.pdf)</sup> 在软件方面，scikit-learn 提供了 `svm.OneClassSVM`、`ensemble.IsolationForest` 和 `neighbors.LocalOutlierFactor`。<sup>[2](https://scikit-learn.org/stable/modules/outlier_detection.html)</sup>

基于扩散的检测是近期的一个变体族。投影遗憾由崔成益（Sungik Choi）及其同事于 2023 年提出，计算测试图像与其基于扩散的投影之间的感知（LPIPS）距离，然后通过与递归投影比较来抵消背景偏差；它是一个即插即用的模块，可与任何预训练的扩散模型和距离度量配合使用，无需额外训练。<sup>[16](https://doi.org/10.48550/arxiv.2312.02615)</sup>

## 应用

有文献记载的应用领域包括乳腺X光片中的肿块样结构检测及其他医学诊断问题、复杂工业系统中的故障和失效检测、结构损伤检测、电子安全系统中的入侵检测（如信用卡和手机欺诈检测）、视频监控、移动机器人、传感器网络、天文星表和文本挖掘。<sup>[1](https://www.robots.ox.ac.uk/~davidc/pubs/NDreview2014.pdf)</sup>

具体的基准数字展示了典型性能。一项在 52 个真实世界多变量表格数据集上对 33 种无监督异常检测算法的研究，是同类比较中规模最大的，发现扩展孤立森林显著优于其他 16 种算法中的 14 种；在“局部”数据集（异常点相对于邻居位于低密度区域）上，kNN 表现最佳，而在“全局”数据集上，EIF 表现最佳，作者因此推荐一个双算法工具箱。<sup>[17](https://jmlr.org/papers/volume25/23-0570/23-0570.pdf)</sup> 在图像单类分类中，一个两阶段框架——先进行自监督分布增强对比学习，再接 OC-SVM——在 CIFAR-10、CIFAR-100、Fashion-MNIST、Cat-vs-Dog 和 [CelebA](https://www.edgepedia.org/zh/celeba) 上达到平均 AUC 89.9，而此前最优结果为 83.1。<sup>[6](https://ar5iv.labs.arxiv.org/html/2011.02578)</sup>

## 局限性与替代方案

**失效模式。** 自编码器可能泛化到未见类别，因而作为新颖性检测器表现不佳，这促使人们在潜在空间采用判别性度量，如将单类 SVM 和 LOF 应用于潜在空间。<sup>[8](https://pure.uva.nl/ws/files/139262176/Improving_novelty_detection_using_the_reconstructions_of_nearest_neighbours.pdf)</sup> 单类 SVM 和核密度估计等经典方法在高维、数据丰富的场景中常常失效，原因是计算可扩展性差和维数灾难。<sup>[13](https://proceedings.mlr.press/v80/ruff18a/ruff18a.pdf)</sup> 软件文档指出，高维离群点检测，或不对内点数据分布做任何假设的离群点检测，极具挑战性，而 `OneClassSVM` 已知对离群点敏感。<sup>[2](https://scikit-learn.org/stable/modules/outlier_detection.html)</sup>

**污染敏感性。** 在无监督设定下，随着训练离群点比例从 0.5% 增加到 10%，性能下降。<sup>[6](https://ar5iv.labs.arxiv.org/html/2011.02578)</sup> 随着训练污染增加，所有方法的性能都下降，其中 SS-DSVDD 最稳健。<sup>[14](http://www.gatsby.ucl.ac.uk/~balaji/udl2019/accepted-papers/UDL2019-paper-15.pdf)</sup>

**度量选择会改变排名。** 一项比较研究推荐 ROC AUC，因为 \( \mathrm{TPR} = \frac{\mathrm{TP}}{\mathrm{TP}+\mathrm{FN}} \) 和 \( \mathrm{FPR} = \frac{\mathrm{FP}}{\mathrm{FP}+\mathrm{TN}} \) 对类别不平衡做了归一化，并建议报告 F1、精确率、召回率和 AUPR，且对每个模型采用最优阈值，因为固定阈值的 F1 可以通过改变测试集中的异常比例来操纵<sup>[5](https://link.springer.com/article/10.1007/s10618-023-00931-x)</sup>, <sup>[18](https://arxiv.org/pdf/2204.09825)</sup>。在入侵数据上采用修正的评估协议后，对若干模型而言，AUROC 相对于 AUPR 高估性能超过 10%：一个深度自编码器在 CSE-CIC-IDS2018 上从 0.882 降到 0.689。<sup>[18](https://arxiv.org/pdf/2204.09825)</sup>

**与邻近任务的比较。** 开放集识别在检测层面与多类新颖性检测相同，但额外要求对分布内样本进行准确分类；分布外检测在规范意义上解决与开放集识别相同的问题。<sup>[19](https://export.arxiv.org/pdf/2110.14051v5.pdf)</sup> 对于深度分类器，[丹·亨德里克斯](https://www.edgepedia.org/zh/hendrycks-dan)（Dan Hendrycks）和凯文·金佩尔（Kevin Gimpel）于 2016 年提出的最大 softmax 概率基线可检测误分类和分布外样本，<sup>[20](https://doi.org/10.48550/arxiv.1610.02136)</sup> 后续方法在训练中使用离群点暴露、<sup>[21](https://doi.org/10.48550/arxiv.1812.04606)</sup> 修正激活、<sup>[22](https://doi.org/10.48550/arxiv.2111.12797)</sup> 或不使用分布外数据进行学习。<sup>[23](https://doi.org/10.48550/arxiv.2002.11297)</sup> 当有一小批同时包含分布内和分布外样本的无标签数据时，适用吉勒·布朗夏尔（Gilles Blanchard）、李圭敏（Gyemin Lee）和克莱顿·斯科特（Clayton Scott）意义上的半监督新颖性检测。<sup>[24](https://doi.org/10.20347/wias.preprint.1471)</sup> 与监督异常检测相比，实际区别在于是否有有标签的异常样本：在离群点观测很少时，模型通常通过单类分类技术获得。<sup>[5](https://link.springer.com/article/10.1007/s10618-023-00931-x)</sup>

## References

1. [A review of novelty detection (Pimentel et al., Signal Processing 2014)](https://www.robots.ox.ac.uk/~davidc/pubs/NDreview2014.pdf)
2. [2.7. Novelty and Outlier Detection, scikit-learn 1.9.1 documentation](https://scikit-learn.org/stable/modules/outlier_detection.html)
3. [Estimating the Support of a High-Dimensional Distribution](https://dl.acm.org/doi/10.1162/089976601750264965)
4. [Fei Tony Liu, Kai Ming Ting, Zhi-Hua Zhou (2012). Isolation-Based Anomaly Detection. ACM Transactions on Knowledge Discovery from Data.](https://doi.org/10.1145/2133360.2133363)
5. [On the evaluation of outlier detection and one-class classification: a comparative study of algorithms, model selection, and ensembles](https://link.springer.com/article/10.1007/s10618-023-00931-x)
6. [Learning and Evaluating Representations for Deep One-class Classification](https://ar5iv.labs.arxiv.org/html/2011.02578)
7. [Support vector domain description (Pattern Recognition Letters, 1999)](https://rduin.nl/papers/prl_99_svdd.pdf)
8. [Improving novelty detection using the reconstructions of nearest neighbours (Mesarcik et al., Array, 2022, DOI 10.1016/j.array.2022.100182)](https://pure.uva.nl/ws/files/139262176/Improving_novelty_detection_using_the_reconstructions_of_nearest_neighbours.pdf)
9. [One-class SVM with non-linear kernel (RBF), scikit-learn example](https://scikit-learn.org/stable/auto_examples/svm/plot_oneclass.html)
10. [One-class classification: taxonomy of study and review of techniques](https://www.cambridge.org/core/journals/knowledge-engineering-review/article/oneclass-classification-taxonomy-of-study-and-review-of-techniques/EEDBC97CFD54B2B65BEB5FCD71593782)
11. [Novelty Detection (Roberts & Tarassenko, 1994)](https://www.robots.ox.ac.uk/~sjrob/Pubs/robertsTarassenko_RAN_1994.pdf)
12. [Sahand Hariri, Matias Carrasco Kind, Robert J. Brunner (2019). Extended Isolation Forest. IEEE Transactions on Knowledge and Data Engineering.](https://doi.org/10.1109/tkde.2019.2947676)
13. [Deep One-Class Classification (Ruff et al., ICML 2018), Deep SVDD](https://proceedings.mlr.press/v80/ruff18a/ruff18a.pdf)
14. [Deep Support Vector Data Description for Unsupervised and Semi-Supervised Anomaly Detection (Ruff et al., UDL 2019 workshop)](http://www.gatsby.ucl.ac.uk/~balaji/udl2019/accepted-papers/UDL2019-paper-15.pdf)
15. [Thomas Schlegl and colleagues (2019). f-AnoGAN: Fast unsupervised anomaly detection with generative adversarial networks. Medical Image Analysis.](https://doi.org/10.1016/j.media.2019.01.010)
16. [Choi, Sungik and colleagues (2023). Projection Regret: Reducing Background Bias for Novelty Detection via Diffusion Models. arXiv (Cornell University).](https://doi.org/10.48550/arxiv.2312.02615)
17. [Unsupervised Anomaly Detection Algorithms on Real-world Data: How Many Do We Need?](https://jmlr.org/papers/volume25/23-0570/23-0570.pdf)
18. [A rigorous study on deep unsupervised anomaly detection: evaluation protocols and baselines (arXiv 2204.09825)](https://arxiv.org/pdf/2204.09825)
19. [A Unified Survey on Anomaly, Novelty, Open-Set, and Out-of-Distribution Detection (Salehi et al., TMLR 2022)](https://export.arxiv.org/pdf/2110.14051v5.pdf)
20. [Hendrycks, Dan, Gimpel, Kevin (2016). A Baseline for Detecting Misclassified and Out-of-Distribution Examples in Neural Networks. arXiv (Cornell University).](https://doi.org/10.48550/arxiv.1610.02136)
21. [Hendrycks, Dan, Mazeika, Mantas, Dietterich, Thomas (2018). Deep Anomaly Detection with Outlier Exposure. arXiv (Cornell University).](https://doi.org/10.48550/arxiv.1812.04606)
22. [Sun, Yiyou, Guo, Chuan, Li, Yixuan (2021). ReAct: Out-of-distribution Detection With Rectified Activations. arXiv (Cornell University).](https://doi.org/10.48550/arxiv.2111.12797)
23. [Hsu, Yen-Chang and colleagues (2020). Generalized ODIN: Detecting Out-of-distribution Image without Learning from Out-of-distribution Data. arXiv (Cornell University).](https://doi.org/10.48550/arxiv.2002.11297)
24. [Blanchard, Gilles, Lee, Gyemin, Scott, Clayton (2009). Semi-supervised novelty detection. .](https://doi.org/10.20347/wias.preprint.1471)

---
*Initially written Sep 29, 2026 · Edited: Oct 15, 2026*

Topic: 技术与人造世界 › 计算技术与数字系统 › 人工智能与数据 › Machine learning and neural computation › Machine learning methods › Supervised, unsupervised, and semi-supervised learning › Anomaly and novelty detection

Copyright 2026 Edgepedia

License: Edgepedia Community License 1.0, https://www.edgepedia.org/edgepedia/license

Source: https://www.edgepedia.org/zh/novelty-detection

English original: https://www.edgepedia.org/novelty-detection
