sklearn.calibration.calibration_curve

sklearn.calibration.calibration_curve(y_true, y_prob, *, normalize=False, n_bins=5, strategy='uniform')

[源码]

计算校准曲线的真正概率和预测概率。

该方法假定输入来自二进制分类器,并将其隔离散为[0,1], 放进箱子。

校准曲线也可称为可靠性图。

用户指南中阅读更多内容。

参数 说明
y_true array-like of shape (n_samples,)
真实目标值
y_prob array-like of shape (n_samples,)
正类概率
normalize bool, default=False
是否需要将y_prob归一化为[0,1]区间,即不是一个适当的概率。如果为真,y_prob中的最小值线性映射到0,最大值映射到1。
n_bins int, default=5
[0,1]间隔的桶数。更多的值需要更多的数据。没有样本的箱子(即y_prob中没有相应的值)将不会被返回,因此返回的数组的值可能小于n_bins值。
strategy {‘uniform’, ‘quantile’}, default=’uniform’
用于定义箱子宽度的策略
uniform:箱子的宽度是相同的
quantile:这些箱子有相同数量的样本,依赖于y_prob
返回 说明
prob_true ndarray of shape (n_bins,) or smaller
每个箱子中正类样本的比例(分数)
prob_pred ndarray of shape (n_bins,) or smaller
每个箱子的平均预测概率。

参考:

Alexandru Niculescu-Mizil and Rich Caruana (2005) Predicting Good Probabilities With Supervised Learning, in Proceedings of the 22nd International Conference on Machine Learning (ICML). See section 4 (Qualitative Analysis of Predictions)

sklearn.calibration.calibration_curve使用示例