# 保形校准（机器学习）

保形校准是一种机器学习技术，它将已训练模型的输出包裹在[保形预测](https://www.edgepedia.org/zh/conformal-prediction)机制中，把原始预测转换为预测集或校准后的预测分布，并附带无分布假设、有限样本的效度保证。普通的事后校准调整预测概率使其平均而言更准确，与此不同，保形校准产生的输出对任意底层模型和任意数据分布都保证其覆盖率或在概率意义下的校准性，前提是满足可交换性假设（即数据顺序不携带信息）。

| 关键事实 | 详情 |
|---|---|
| 输出 | 预测集（分类）、区间（回归）或校准后的预测分布 |
| 保证 | 无分布假设、非渐近：集合以用户指定的概率包含真实标签，例如90% <sup>[1](https://dl.acm.org/doi/10.1561/2200000101)</sup> |
| 核心假设 | 校准数据与测试数据的可交换性 <sup>[2](https://ar5iv.labs.arxiv.org/html/2405.01976)</sup> |
| 关键阈值 | \( q_{\alpha} \)，即校准非一致性得分的 ⌈(1−α)(n+1)⌉/n 经验分位数 <sup>[3](https://arxiv.org/html/2505.15437v2)</sup> |
| 典型校准集规模 | 约1,000个样本量级 <sup>[2](https://ar5iv.labs.arxiv.org/html/2405.01976)</sup> |
| 成本（分裂变体） | 一次模型拟合步骤；排序步骤基本无额外开销 <sup>[4](https://www.stat.cmu.edu/~ryantibs/papers/conformal.pdf)</sup> |
| 作为命名方法提出 | “保形校准器”，Vovk、Petej、Toccaceli和Gammerman，2019 <sup>[5](https://doi.org/10.48550/arxiv.1902.06579)</sup> |

## 工作原理

保形校准建立在一个非一致性度量之上，该函数为每个样本分配一个得分，使得交换两个样本时它们的得分也随之交换。<sup>[6](https://www.jmlr.org/papers/volume9/shafer08a/shafer08a.pdf)</sup> 得分在校准集和新输入的候选标签上计算；得分低于数据驱动分位数的标签构成预测集。由于可交换数据使新得分在 \( n+1 \) 个得分中的秩服从均匀分布，所得集合以至少 \( 1-\alpha \) 的概率包含真实标签，且无需任何分布或模型假设。<sup>[1](https://dl.acm.org/doi/10.1561/2200000101)</sup>

在其分布形式中，保形校准将任意预测系统转变为在概率意义下校准的系统：当随机训练观测、一个测试观测以及 \( \tau \sim U[0,1] \) 三者相互独立时，对每个 \( \alpha \in [0,1] \) 有 \( P(Q(Z_1,\ldots,Z_n,Z,\tau) \le \alpha) = \alpha \)，因此输出分布是均匀的。<sup>[7](http://proceedings.mlr.press/v128/vovk20a/vovk20a.pdf)</sup> 输入预测系统无需满足任何效度性质；校准步骤提供保证。<sup>[7](http://proceedings.mlr.press/v128/vovk20a/vovk20a.pdf)</sup>

## 实施方法

标准的分裂保形工作流程包含四个步骤 <sup>[4](https://www.stat.cmu.edu/~ryantibs/papers/conformal.pdf)</sup><sup> • </sup><sup>[3](https://arxiv.org/html/2505.15437v2)</sup>：

1. 将数据分为训练集和留出的校准集。
2. 在训练集上拟合模型，并在校准集上计算非一致性得分 \( s_i = s(x_i, y_i) \)。
3. 计算调整分位数 \( \hat{q} = \mathrm{Quantile}(\{s_i\}; \lceil (n+1)(1-\alpha) \rceil / n) \)。<sup>[8](https://royalsocietypublishing.org/rsta/article/384/2327/20260061/483104/Uncertainty-aware-large-language-models-a-scoping)</sup>
4. 对新输入输出集合 \( C_{\alpha}(x) = \{ y: s(x,y) \le q_{\alpha} \} \)。<sup>[3](https://arxiv.org/html/2505.15437v2)</sup>

对于独立同分布数据，分裂保形带满足 \( P(Y_{n+1} \in C_{\mathrm{split}}(X_{n+1})) \ge 1-\alpha \)；若残差具有连续联合分布，覆盖率至多为 \( 1-\alpha + 2/(n+2) \)。<sup>[4](https://www.stat.cmu.edu/~ryantibs/papers/conformal.pdf)</sup>

## 起源

现在被称为保形预测的框架使用非一致性得分来构造保形p值。<sup>[1](https://dl.acm.org/doi/10.1561/2200000101)</sup> Vovk、Gammerman和Shafer（2005）的专著《随机世界中的算法学习》整合了该理论 <sup>[9](https://doi.org/10.1007/b106715)</sup>，Shafer和Vovk（2007）的教程成为标准入门文献。<sup>[10](https://doi.org/10.48550/arxiv.0706.3188)</sup> 分裂保形预测是当今最常用的计算高效形式。<sup>[11](https://par.nsf.gov/servlets/purl/10645972)</sup> 无分布预测推断的基本思想可追溯到20世纪40年代的容忍区域，见于Wilks（1941–1942）、Wald（1943）和Tukey（1947）的工作。<sup>[11](https://par.nsf.gov/servlets/purl/10645972)</sup> 保形校准作为一种命名方法——将任意预测系统校准为在概率意义下校准的系统——由Vladimir Vovk及其同事在“保形校准器”（2019）中提出，发表于arXiv。<sup>[5](https://doi.org/10.48550/arxiv.1902.06579)</sup>

## 变体

**分裂保形**使用一个校准集和一次拟合步骤，以统计效率换取速度。<sup>[1](https://dl.acm.org/doi/10.1561/2200000101)</sup> **完全保形**使用整个训练集而非单独的校准集，并对每个可能的标签重新拟合模型，计算成本高但具有相同的效度保证。<sup>[2](https://ar5iv.labs.arxiv.org/html/2405.01976)</sup> **交叉保形**预测器将每个交叉验证折作为校准集使用一次 <sup>[2](https://ar5iv.labs.arxiv.org/html/2405.01976)</sup>；交叉保形预测系统组合多个分裂保形预测系统，更高效地利用数据但在概率意义下失去自动校准性。<sup>[7](http://proceedings.mlr.press/v128/vovk20a/vovk20a.pdf)</sup>

**jackknife+**由Rina Foygel Barber、Emmanuel J. Candès、[Aaditya Ramdas](https://www.edgepedia.org/zh/aaditya-ramdas)和Ryan J. Tibshirani（2021）提出，在留一残差之外还使用测试点处的留一预测，对任何对称对待训练点的算法在可交换性下给出严格的覆盖率；原始jackknife的覆盖率可能消失，而jackknife+对稳定算法达到近乎精确的覆盖率。<sup>[12](https://doi.org/10.1214/20-aos1965)</sup> 它可扩展到K折交叉验证，即**CV+**。<sup>[12](https://doi.org/10.1214/20-aos1965)</sup>

**蒙德里安保形预测**使用分组函数按共同特征拆分校准数据，并逐组计算保形得分，给出分组条件效度。<sup>[13](https://arxiv.org/html/2401.08058)</sup> **APS和RAPS**（正则化自适应预测集）由Angelopoulos、Bates、Malik和Jordan（2020）提出，接受任意基分类器并返回保证达到预设错误水平同时保持较小平均规模的预测集。<sup>[14](https://doi.org/10.48550/arxiv.2009.14193)</sup> **保形分位数回归（CQR）**由Romano、Patterson和Candès（2019）提出，将分位数回归与保形校正相结合。<sup>[15](https://doi.org/10.48550/arxiv.1905.03222)</sup> **康定斯基保形预测**将保形预测的归纳（分裂）形式应用于图像分割，因为原始直推方法计算需求过高。<sup>[16](https://ar5iv.labs.arxiv.org/html/2311.11837)</sup>

**保形风险控制**由Angelopoulos、Bates、Fisch、Lei和Schuster（2022）提出，将保形预测扩展到控制任意单调损失函数的期望值，推广了分裂保形预测及其覆盖率保证，且紧至 \( O(1/n) \) 因子。<sup>[17](https://doi.org/10.48550/arxiv.2208.02814)</sup> 它建立在Bates、Angelopoulos、Lei、Malik和Jordan（2021）的《风险控制预测集》<sup>[18](https://doi.org/10.1145/3478535)</sup>之上，而Angelopoulos、Bates、Candès、Jordan和Lei的“先学后测”方法将风险控制预测集从单调风险推广到任意统计误差概念。<sup>[19](https://doi.org/10.1214/24-aoas1998)</sup>

**自校准保形预测**（2024）将Venn-Abers校准与保形预测相结合，在给出预测区间的同时提供校准后的点预测，且区间以这些预测为条件具有有限样本效度。<sup>[20](https://proceedings.neurips.cc/paper_files/paper/2024/file/c1c49aba08e6c90f2b1f85751f497a2f-Paper-Conference.pdf)</sup>

## 应用

保形预测是一种范式，用于在医疗诊断等高风险场景中为黑箱模型预测创建统计严格的不确定性集和区间。<sup>[1](https://dl.acm.org/doi/10.1561/2200000101)</sup> 它已被应用于组织病理学图像分类、皮肤病学、通过分位数回归的视网膜血管分割以及放射学报告生成。<sup>[21](https://arxiv.org/html/2512.14727v1)</sup> 2026年皇家学会的范围综述记录了越来越多用于大语言模型不确定性量化的保形预测方法。<sup>[8](https://royalsocietypublishing.org/rsta/article/384/2327/20260061/483104/Uncertainty-aware-large-language-models-a-scoping)</sup>

## 局限性与替代方法

**边际覆盖率与条件覆盖率。** 该保证是边际的：\( P(Y \in C_{\alpha}(X)) \ge 1-\alpha \) 是在数据分布上的平均。对每个 \( x \) 都满足条件覆盖率 \( P(Y \in C_{\alpha}(X) \mid X=x) \ge 1-\alpha \) 在没有额外分布假设的情况下是不可能的 <sup>[3](https://arxiv.org/html/2505.15437v2)</sup>；一个达到95%边际覆盖率的区间在特定情境下可能表现出任意差的覆盖率。<sup>[20](https://proceedings.neurips.cc/paper_files/paper/2024/file/c1c49aba08e6c90f2b1f85751f497a2f-Paper-Conference.pdf)</sup>

**校准集条件覆盖率。** 以固定小校准集为条件的覆盖率可能以高概率远低于期望水平，这在临床实践中无法重新校准时是一个值得关注的问题。<sup>[21](https://arxiv.org/html/2512.14727v1)</sup>

**分布偏移与非可交换性。** 保证建立在可交换性之上。分裂保形预测通过添加小的覆盖率惩罚对许多非可交换过程仍然有效；对于 \( \beta \)-混合数据，覆盖率变为 \( P[Y_i \in C] \ge 1-\alpha-\eta \)，其中 \( \eta = (1-\alpha)/(n_{\mathrm{cal}}+1) \)。<sup>[22](https://jmlr.org/papers/volume25/23-1553/23-1553.pdf)</sup> 加权保形预测在从训练分布到测试分布的协变量偏移下形成有效预测集。<sup>[1](https://dl.acm.org/doi/10.1561/2200000101)</sup> 自适应覆盖率策略逐样本调整 \( \alpha \)，以集合规模的适度增加换取有原则的事后工作点选择。<sup>[23](https://raw.githubusercontent.com/mlresearch/v300/main/assets/gauthier26a/gauthier26a.pdf)</sup>

**保证的范围。** 保形保证仅对所选的 \( \alpha \) 成立，不扩展到其他 \( \alpha \) 值。<sup>[3](https://arxiv.org/html/2505.15437v2)</sup>

**与标准校准的关系。** 事后校准方法使用留出验证数据学习一个校准映射，对已训练模型的预测进行变换，使其校准得更好 <sup>[24](https://link.springer.com/article/10.1007/s10994-023-06336-7)</sup>；经典选择包括温度缩放、[Platt缩放](https://www.edgepedia.org/zh/platt-scaling)、等渗回归、狄利克雷校准和自适应温度缩放。<sup>[3](https://arxiv.org/html/2505.15437v2)</sup> 保形校准则提供对任意模型有效的有限样本覆盖率或在概率意义下校准的陈述。<sup>[1](https://dl.acm.org/doi/10.1561/2200000101)</sup> 它类似于等渗校准，不同之处在于它使用随机化函数调整经验分位数而非等渗回归，以不连续和随机化的分布预测为代价获得强校准保证。<sup>[25](https://proceedings.mlr.press/v162/marx22a/marx22a.pdf)</sup> 分位数重校准等价于在每个覆盖率水平 \( \alpha \in [0,1] \) 上对左区间进行分布保形预测。<sup>[26](https://orbi.umons.ac.be/bitstream/20.500.12907/45907/1/2306.02738.pdf)</sup>

**替代方法。** [温度](https://www.edgepedia.org/zh/temperature)缩放、Platt缩放、等渗回归、狄利克雷校准和自适应温度缩放直接处理概率校准，但不具备保形式的有限样本覆盖率保证。<sup>[3](https://arxiv.org/html/2505.15437v2)</sup> 保形分位数回归将分位数回归与保形校正相结合。<sup>[15](https://doi.org/10.48550/arxiv.1905.03222)</sup>

## References

1. [Conformal Prediction: A Gentle Introduction (Foundations and Trends in Machine Learning, Vol 16, No 4; merged with arXiv 2107.07511)](https://dl.acm.org/doi/10.1561/2200000101)
2. [Conformal Prediction for Natural Language Processing: A Survey](https://ar5iv.labs.arxiv.org/html/2405.01976)
3. [Adaptive Cumulative Mass Calibration with Conformal Prediction (CMCE)](https://arxiv.org/html/2505.15437v2)
4. [Distribution-Free Predictive Inference for Regression (Lei et al.)](https://www.stat.cmu.edu/~ryantibs/papers/conformal.pdf)
5. [Vovk, Vladimir and colleagues (2019). Conformal calibrators. arXiv (Cornell University).](https://doi.org/10.48550/arxiv.1902.06579)
6. [A Tutorial on Conformal Prediction (Shafer & Vovk, JMLR 2008)](https://www.jmlr.org/papers/volume9/shafer08a/shafer08a.pdf)
7. [Conformal calibrators (Vovk et al., COPA 2020, PMLR v128)](http://proceedings.mlr.press/v128/vovk20a/vovk20a.pdf)
8. [Uncertainty-aware large language models: a scoping review of conformal prediction methods (Phil. Trans. R. Soc. A, 2026)](https://royalsocietypublishing.org/rsta/article/384/2327/20260061/483104/Uncertainty-aware-large-language-models-a-scoping)
9. [Vovk, Vladimir, Gammerman, Alex, Shafer, Glenn (2005). Algorithmic Learning in a Random World. .](https://doi.org/10.1007/b106715)
10. [Shafer, Glenn, Vovk, Vladimir (2007). A tutorial on conformal prediction. arXiv (Cornell University).](https://doi.org/10.48550/arxiv.0706.3188)
11. [Learn then test: Calibrating predictive algorithms to achieve risk control (Angelopoulos, Bates, Fisch, Lei, Schuster)](https://par.nsf.gov/servlets/purl/10645972)
12. [Rina Foygel Barber and colleagues (2021). Predictive inference with the jackknife+. The Annals of Statistics.](https://doi.org/10.1214/20-aos1965)
13. [Toward Clinically Trustworthy Deep Learning (Mondrian conformal prediction for head CT)](https://arxiv.org/html/2401.08058)
14. [Angelopoulos, Anastasios and colleagues (2020). Uncertainty Sets for Image Classifiers using Conformal Prediction. arXiv (Cornell University).](https://doi.org/10.48550/arxiv.2009.14193)
15. [Romano, Yaniv, Patterson, Evan, Candès, Emmanuel J. (2019). Conformalized Quantile Regression. arXiv (Cornell University).](https://doi.org/10.48550/arxiv.1905.03222)
16. [Kandinsky Conformal Prediction: Efficient Calibration of Image Segmentation Algorithms](https://ar5iv.labs.arxiv.org/html/2311.11837)
17. [Angelopoulos, Anastasios N. and colleagues (2022). Conformal Risk Control. arXiv (Cornell University).](https://doi.org/10.48550/arxiv.2208.02814)
18. [Stephen Bates and colleagues (2021). Distribution-free, Risk-controlling Prediction Sets. Journal of the ACM.](https://doi.org/10.1145/3478535)
19. [Anastasios N. Angelopoulos and colleagues (2025). Learn then test: Calibrating predictive algorithms to achieve risk control. The Annals of Applied Statistics.](https://doi.org/10.1214/24-aoas1998)
20. [Self-Calibrating Conformal Prediction (NeurIPS 2024; merged with arXiv 2402.07307)](https://proceedings.neurips.cc/paper_files/paper/2024/file/c1c49aba08e6c90f2b1f85751f497a2f-Paper-Conference.pdf)
21. [A Critical Perspective on Finite Sample Conformal Prediction Theory in Medical Applications](https://arxiv.org/html/2512.14727v1)
22. [Split Conformal Prediction and Non-Exchangeable Data (JMLR vol. 25)](https://jmlr.org/papers/volume25/23-1553/23-1553.pdf)
23. [Adaptive Coverage Policies in Conformal Prediction (PMLR v300)](https://raw.githubusercontent.com/mlresearch/v300/main/assets/gauthier26a/gauthier26a.pdf)
24. [Classifier calibration: a survey on how to assess and improve predicted class probabilities (Machine Learning, Springer)](https://link.springer.com/article/10.1007/s10994-023-06336-7)
25. [Modular Conformal Calibration (Marx et al., ICML 2022, PMLR v162; merged with arXiv 2206.11468)](https://proceedings.mlr.press/v162/marx22a/marx22a.pdf)
26. [A Large-Scale Study of Probabilistic Calibration in Neural Network Regression](https://orbi.umons.ac.be/bitstream/20.500.12907/45907/1/2306.02738.pdf)

---
*Initially written Sep 29, 2026 · Reviewed: Sep 30, 2026 · Edited: Sep 30, 2026; Oct 25, 2026 · Last review: Sep 30, 2026*

Topic: 技术与人造世界 › 计算技术与数字系统 › 人工智能与数据 › Machine learning and neural computation › Machine learning methods

Copyright 2026 Edgepedia

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

Source: https://www.edgepedia.org/zh/conformal-calibration-machine-learning

English original: https://www.edgepedia.org/conformal-calibration-machine-learning
