# Platt缩放

**Platt缩放**是一种参数化的事后校准方法，它通过将S形函数拟合到分类器的原始输出分数上，把这些分数映射为概率，最初由[John Platt](https://www.edgepedia.org/zh/john-c-platt)为支持向量机提出。分类器先完成训练；随后拟合两个参数，使得施加于原始分数的S形函数给出后验概率的估计。这种方法之所以广为人知，部分原因在于2000年前后SVM的流行。<sup>[1](https://link.springer.com/article/10.1007/s10994-023-06336-7)</sup> Platt陈述的动机是保持SVM的稀疏性：直接用logit链接和正则化最大似然训练核分类器会产生非稀疏的核机器，因此改为先训练SVM，之后再拟合一个额外的S形函数，由此得到的概率质量与正则化最大似然核方法相当。<sup>[2](https://www.researchgate.net/publication/2594015_Probabilistic_Outputs_for_Support_Vector_Machines_and_Comparisons_to_Regularized_Likelihood_Methods)</sup>

| 关键事实 | 细节 |
|---|---|
| 作用 | 将S形函数拟合到已训练分类器的原始分数上，在保持基模型不变的同时将其映射为后验概率<sup>[2](https://www.researchgate.net/publication/2594015_Probabilistic_Outputs_for_Support_Vector_Machines_and_Comparisons_to_Regularized_Likelihood_Methods)</sup> |
| 校准映射 | \( P(y=1 \mid f) = 1/(1+\exp(Af+B)) \)，其中A和B通过梯度下降以最大似然拟合<sup>[3](https://icml.cc/Conferences/2005/proceedings/papers/079_GoodProbabilities_NiculescuMizilCaruana.pdf)</sup> |
| 伪目标值 | 目标值 \( t_{+} = (N_{+}+1)/(N_{+}+2) \) 和 \( t_{-} = 1/(N_{-}+2) \) 取代标签1和0，以避免对极端标签过拟合<sup>[4](https://www.csie.ntu.edu.tw/~cjlin/papers/plattprob.pdf)</sup> |
| 拟合数据 | 必须是留出数据或经过交叉验证；在训练数据上拟合会使S形函数偏向0/1阶跃函数<sup>[3](https://icml.cc/Conferences/2005/proceedings/papers/079_GoodProbabilities_NiculescuMizilCaruana.pdf)</sup> |
| 样本量规则 | 校准集低于约1000个样本时，Platt缩放优于等渗回归；样本量更大时两者几乎无法区分<sup>[3](https://icml.cc/Conferences/2005/proceedings/papers/079_GoodProbabilities_NiculescuMizilCaruana.pdf)</sup> |
| 标准实现 | LIBSVM自2.6版起；scikit-learn的CalibratedClassifierCV，method="sigmoid"<sup>[4](https://www.csie.ntu.edu.tw/~cjlin/papers/plattprob.pdf)</sup><sup> • </sup><sup>[5](https://scikit-learn.org/stable/modules/calibration.html)</sup> |
| 已知局限 | S形函数的形状可能将概率推离中心并导致过度自信，且无法纠正非单调的校准偏差<sup>[1](https://link.springer.com/article/10.1007/s10994-023-06336-7)</sup><sup> • </sup><sup>[6](https://arxiv.org/html/2305.00070)</sup> |

## 为什么分类器分数不是概率

标准SVM根本不输出概率。它的分数是到决策边界的有符号几何距离，一个位于 \([-\infty, +\infty]\) 尺度上的数，其大小反映的是间隔，而非标签的可能性。这就是为什么这种变换被称为“缩放”而非校准，名称本身就保留了这一区分。<sup>[1](https://link.springer.com/article/10.1007/s10994-023-06336-7)</sup>因此标准SVM不提供校准后的后验概率，这正是事后S形函数的动机所在。<sup>[2](https://www.researchgate.net/publication/2594015_Probabilistic_Outputs_for_Support_Vector_Machines_and_Comparisons_to_Regularized_Likelihood_Methods)</sup>

SVM并非唯一校准不良的模型。朴素贝叶斯因其不切实际的独立性假设而将预测概率推向0和1，而袋装树和神经网络则表现出很小或没有偏差，无需任何校正就能产生校准良好的概率。<sup>[3](https://icml.cc/Conferences/2005/proceedings/papers/079_GoodProbabilities_NiculescuMizilCaruana.pdf)</sup>这在实践中很重要：对于神经网络、袋装树和逻辑回归等已经校准良好的方法，Platt缩放和[等渗回归](https://www.edgepedia.org/zh/isotonic-regression)都不会带来多少改进，校准甚至可能损害性能。<sup>[3](https://icml.cc/Conferences/2005/proceedings/papers/079_GoodProbabilities_NiculescuMizilCaruana.pdf)</sup>

## 方法

**校准映射。** Platt缩放通过逻辑函数变换分类器的分数 \( f \)

\[ P(y=1 \mid f) = \frac{1}{1 + \exp(Af + B)} \]

其中两个实数参数A和B在一组分数-标签对 \( (f_i, y_i) \) 上以最大似然拟合，使用梯度下降。<sup>[3](https://icml.cc/Conferences/2005/proceedings/papers/079_GoodProbabilities_NiculescuMizilCaruana.pdf)</sup>写成对数几率形式，映射为 \( m^{a,b}(f) = \operatorname{sigmoid}(a \cdot \operatorname{logit}(f) + b) \)：该方法假设分类器的输出与正例的对数几率成正比。<sup>[6](https://arxiv.org/html/2305.00070)</sup><sup> • </sup><sup>[7](https://rdrr.io/github/bioinf-jku/platt/f/inst/doc/platt.pdf)</sup>这两个参数有直接的解释。如果模型过度自信，分数偏向0或1，选择 \( a \in (0,1) \) 可改善校准；如果模型自信不足，则 \( a > 1 \)；对0或1的系统性偏差通过 \( b > 0 \) 或 \( b < 0 \) 来纠正。<sup>[6](https://arxiv.org/html/2305.00070)</sup>

逻辑形式并非任意选择。如果假设对于每个类别，未校准的分数服从具有共同方差的正态分布，就可以从第一原理推导出来。<sup>[1](https://link.springer.com/article/10.1007/s10994-023-06336-7)</sup>Platt报告称，这一假设对于使用常见核的SVM在经验上是合理的，尽管它一般不成立。<sup>[5](https://scikit-learn.org/stable/modules/calibration.html)</sup>

**伪数据技巧。** 用恰好为1和0的目标值拟合S形函数会使最大似然问题变得病态。Platt转而使用平滑目标值：对于 \( N_{+} \) 个正例，目标值为 \( t_{+} = (N_{+}+1)/(N_{+}+2) \)，对于 \( N_{-} \) 个负例，目标值为 \( t_{-} = 1/(N_{-}+2) \)。<sup>[4](https://www.csie.ntu.edu.tw/~cjlin/papers/plattprob.pdf)</sup><sup> • </sup><sup>[3](https://icml.cc/Conferences/2005/proceedings/papers/079_GoodProbabilities_NiculescuMizilCaruana.pdf)</sup>这些目标值永远不是0或1，因此拟合不会被少数标签驱动到极端概率，从而避免了对极端标签的过拟合。<sup>[3](https://icml.cc/Conferences/2005/proceedings/papers/079_GoodProbabilities_NiculescuMizilCaruana.pdf)</sup>

## 拟合数据与样本量

参数必须在基模型未见过的数据上拟合。如果使用训练模型的同一数据，一个能完美区分训练集并将所有负例排在所有正例之前的模型会迫使S形函数只输出0/1阶跃函数，从而破坏校准。<sup>[3](https://icml.cc/Conferences/2005/proceedings/papers/079_GoodProbabilities_NiculescuMizilCaruana.pdf)</sup>当训练数据和校准数据都很稀缺时，Platt提出将数据分为三折：在两折上训练模型，在第三折的预测上拟合校准器，并在测试时对三个模型-校准器对取平均。<sup>[1](https://link.springer.com/article/10.1007/s10994-023-06336-7)</sup>scikit-learn的CalibratedClassifierCV遵循同样的原则，将数据分成k个（train_set, test_set）对，使校准器始终看到无偏的预测。<sup>[5](https://scikit-learn.org/stable/modules/calibration.html)</sup>

经典的样本量指导来自Niculescu-Mizil和Caruana在ICML 2005上的学习曲线分析：对于少于约1000个样本的中小型校准集，Platt缩放比等渗回归表现更好，而对于更大的集合，两者几乎无法区分。等渗回归是更强大的方法，能够纠正任何单调失真，但在数据稀缺时更容易过拟合。<sup>[3](https://icml.cc/Conferences/2005/proceedings/papers/079_GoodProbabilities_NiculescuMizilCaruana.pdf)</sup>scikit-learn文档给出了相同的阈值：当样本超过约1000个时，等渗回归的表现与S形函数相当或更好，而在样本远少于此数时不推荐使用，因为那时它会过拟合。<sup>[5](https://scikit-learn.org/stable/modules/calibration.html)</sup><sup> • </sup><sup>[8](https://scikit-learn.org/stable/modules/generated/sklearn.calibration.CalibratedClassifierCV.html)</sup>

## 数据说话

校准质量通常用期望校准误差（ECE）来衡量，即预测置信度与观测准确率之间的差距，以及用对数损失和布里尔分数等适当评分规则来衡量。在2025年的一项实证比较中，未校准的ECE为0.1569，使用Platt缩放后降至0.0394，使用等渗回归后降至0.0321；在20个分类器-特征组合中，等渗回归有18个取得了更低的ECE，\( p < 0.001 \)。然而对数损失更有利于Platt缩放，为0.1037 ± 0.0210，优于等渗回归的0.1131 ± 0.0598，两者均优于未校准的0.2626 ± 0.0142。<sup>[9](https://arxiv.org/html/2509.23665)</sup>

2026年的一项现代表格模型基准测试对每个校准器运行了3,150次（21个分类器、30个二分类TabArena-v0.1任务、5折交叉验证）。Platt缩放仅在49.8%的运行中改善了对数损失，没有显示出一致的方向性优势，而等渗回归的对数损失平均相对变化为+3.22%，仅在43.7%的运行中改善了对数损失。在同一基准测试中，Venn–Abers取得了最大的平均对数损失降低（−14.17%），beta校准取得了最高的改善率（67.1%），而平均AUC-ROC全程变化不到1%，因此校准变化在区分度指标中基本上不可见。<sup>[10](https://proceedings.mlr.press/v329/manokhin26a.html)</sup>

这些近期结果与2005年的发现存在张力，后者认为对于最大间隔方法，即使校准集很小，校准也能带来改善，并且在校准之后，八个分类问题中校准最好的方法包括提升树、随机森林和SVM。<sup>[3](https://icml.cc/Conferences/2005/proceedings/papers/079_GoodProbabilities_NiculescuMizilCaruana.pdf)</sup>

## 与其他校准方法的比较

**等渗回归**是非参数对应方法：一种更强大的方法，能够纠正任何单调失真，而Platt缩放在预测概率的失真呈S形时最为有效。<sup>[3](https://icml.cc/Conferences/2005/proceedings/papers/079_GoodProbabilities_NiculescuMizilCaruana.pdf)</sup>Platt缩放能容忍少量的模型设定错误：当实际校准函数偏离S形时，由此产生的校准误差以渐进、良态的方式增长。<sup>[9](https://arxiv.org/html/2509.23665)</sup>对于非常不平衡数据集上校准很差的分类器，可能更倾向于S形校准，因为其额外的截距参数会将决策边界移向多数类。<sup>[8](https://scikit-learn.org/stable/modules/generated/sklearn.calibration.CalibratedClassifierCV.html)</sup>

**深度网络方法**源自同样的思想。温度缩放在对数几率上施加单一温度参数 \( t \) 后再做softmax，已成为深度学习研究中的默认方法；向量缩放将其扩展为温度向量 \( w \in \mathbb{R}^K \) 和截距向量 \( b \in \mathbb{R}^K \)，分别为K个类别提供各自的温度和截距；Dirichlet校准是beta校准的多类别扩展。这些方法中的大多数，包括Platt缩放、温度缩放及其变体以及beta校准，都优化对数损失，而等渗校准优化布里尔分数。<sup>[1](https://link.springer.com/article/10.1007/s10994-023-06336-7)</sup>

2025年的SVM比较值得直说：等渗回归将具有信息特征的SVM的ECE从0.021 ± 0.006降至0.015 ± 0.006，相对于Platt缩放的[Cohen's d](https://www.edgepedia.org/zh/cohens-d) = 2.317，其作者称这一结果挑战了Platt缩放对SVM校准最优的传统观点。<sup>[9](https://arxiv.org/html/2509.23665)</sup>

## 实际使用

**LIBSVM**自2.6版（Chang和Lin，2001）起就包含了Platt程序的简单而稳健的实现。之所以需要稳健的代码，是因为Platt的原始算法虽然在声纳数据集上表现合理，但在穿梭机数据集上遇到了大量溢出错误，需要更多迭代，有时无法返回具有像样目标值的解；Lin、Lin和Weng的注记提供了数值稳定的拟合过程。<sup>[4](https://www.csie.ntu.edu.tw/~cjlin/papers/plattprob.pdf)</sup>

**scikit-learn**通过CalibratedClassifierCV暴露该方法，其method参数提供“sigmoid”（Platt的方法，实现为分类器输出上的二分类逻辑回归模型）、“isotonic”，以及1.2版新增的“temperature”缩放。<sup>[8](https://scikit-learn.org/stable/modules/generated/sklearn.calibration.CalibratedClassifierCV.html)</sup>pycalib库将PlattScaling实现为模型输出上带负对数似然损失的逻辑回归，被描述为一种参数化方法，用于为非概率二分类器输出校准后的后验概率。<sup>[11](https://jonathanwenger.github.io/pycalib/automod/pycalib.calibration_methods.PlattScaling.html)</sup>一个R包为Platt缩放提供了快速稳健的优化算法，用于生物信息学场景。<sup>[7](https://rdrr.io/github/bioinf-jku/platt/f/inst/doc/platt.pdf)</sup>

## 局限与最新进展

S形函数形式本身就是一种约束。由于校准映射被限制为S形，它实际上将概率推离中心，可能导致过度自信；又由于映射接受标量输入，校准概率分类器需要先进行logit变换等转换。<sup>[1](https://link.springer.com/article/10.1007/s10994-023-06336-7)</sup>更根本地说，由于 \( m^{a,b} \) 始终是单调变换，对于某些数据生成分布，即使数据是独立同分布的，Platt缩放也必然失败，这推动了对漂移分布的扩展。<sup>[6](https://arxiv.org/html/2305.00070)</sup>该方法在用于类别不平衡的欠采样之后应用时也有已知局限；它有时被称为逻辑校准，尽管一些作者仍然区分两者。<sup>[12](https://arxiv.org/pdf/2410.18144)</sup>

LLM时代催生了这一方法的后继方法，而没有将其弃用。Thermometer（ICML 2024）从多任务数据中学习一个辅助模型来校准大型语言模型，计算高效且保持LLM的准确率。<sup>[13](https://proceedings.mlr.press/v235/shen24c.html)</sup>自适应温度缩放将温度缩放谱系应用于语言模型词元对数几率。<sup>[14](https://aclanthology.org/2024.emnlp-main.1007.pdf)</sup>具有因果解释的自适应Platt缩放已被开发用于自我反思的语言模型不确定性估计，包括思维链推理的设置。<sup>[15](https://aclanthology.org/2025.findings-emnlp.999.pdf)</sup>[温度](https://www.edgepedia.org/zh/temperature)缩放可能仍然是文献中使用最广泛的事后校准方法，作为解耦校准器在留出集上拟合，这一做法部分源于卷积网络在部署数据与训练数据不同时倾向于产生过度自信的预测。<sup>[16](https://link.springer.com/article/10.1007/s00521-024-09505-4)</sup>

## References

1. [Classifier calibration: a survey on how to assess and improve predicted class probabilities, Machine Learning (2023)](https://link.springer.com/article/10.1007/s10994-023-06336-7)
2. [Platt, J. Probabilistic Outputs for Support Vector Machines and Comparisons to Regularized Likelihood Methods](https://www.researchgate.net/publication/2594015_Probabilistic_Outputs_for_Support_Vector_Machines_and_Comparisons_to_Regularized_Likelihood_Methods)
3. [Niculescu-Mizil, A., Caruana, R. Predicting Good Probabilities With Supervised Learning, ICML 2005](https://icml.cc/Conferences/2005/proceedings/papers/079_GoodProbabilities_NiculescuMizilCaruana.pdf)
4. [Lin, H.-T., Lin, C.-J., Weng, R. A Note on Platt's Probabilistic Outputs for Support Vector Machines](https://www.csie.ntu.edu.tw/~cjlin/papers/plattprob.pdf)
5. [scikit-learn documentation, 1.16. Probability calibration](https://scikit-learn.org/stable/modules/calibration.html)
6. [Online Platt Scaling with Calibeating, arXiv](https://arxiv.org/html/2305.00070)
7. [platt: Robust Platt scaling of prediction values, R package vignette](https://rdrr.io/github/bioinf-jku/platt/f/inst/doc/platt.pdf)
8. [scikit-learn API reference, CalibratedClassifierCV](https://scikit-learn.org/stable/modules/generated/sklearn.calibration.CalibratedClassifierCV.html)
9. [Calibration Meets Reality: Making Machine Learning Predictions Trustworthy, arXiv (2025)](https://arxiv.org/html/2509.23665)
10. [When Post-Hoc Calibration Hurts: Platt Scaling and Isotonic Regression on Modern Tabular Models, PMLR v329 (2026)](https://proceedings.mlr.press/v329/manokhin26a.html)
11. [PlattScaling, pycalib documentation](https://jonathanwenger.github.io/pycalib/automod/pycalib.calibration_methods.PlattScaling.html)
12. [Using Platt's scaling for calibration after undersampling – limitations and how to address them, arXiv (2024)](https://arxiv.org/pdf/2410.18144)
13. [Thermometer: Towards Universal Calibration for Large Language Models, ICML 2024](https://proceedings.mlr.press/v235/shen24c.html)
14. [Calibrating Language Models with Adaptive Temperature Scaling, EMNLP 2024](https://aclanthology.org/2024.emnlp-main.1007.pdf)
15. [Adaptive Platt Scaling with Causal Interpretations for Self-Reflective Language Model Uncertainty Estimates, EMNLP 2025 Findings](https://aclanthology.org/2025.findings-emnlp.999.pdf)
16. [Adaptive temperature scaling for robust calibration of deep neural networks, Neural Computing and Applications (2024)](https://link.springer.com/article/10.1007/s00521-024-09505-4)

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

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

Copyright 2026 Edgepedia

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

Source: https://www.edgepedia.org/zh/platt-scaling

English original: https://www.edgepedia.org/platt-scaling
