在校准分类RCV的documentation中说明
The samples that are used to train the calibrator should not be used to train the target classifier.
据我所知;如果我们用X_train
来训练我们的model
,那么我们就不应该用X_train
来训练calibrator
(因为我假设它只是把X_train
映射到model.predict_proba
?)
但是,使用用于model
超参数优化的验证集X_val
来校准calibrator
是否公平
CalibratedClassifierCV
在数据样本上拟合分类器,然后查看预测的概率是否与不同数据集上的实际标签很好地对应。然后,它尝试调整(“校准”)proba,以便对于proba为0.7 eg的一组样本,将有大约0.7个带有“1”的真实标签(对于二进制分类)注意,训练分类器和拟合校准器是在不同的数据集上进行的,以解释对未知数据的可能偏差。这可以通过两种不同的方式完成:
CalibratedClassifierCV(..., cv=None, ensemble=True)
。您可以根据提供的cv策略分割列车数据,例如cv=5
。通常,在k-1折叠上训练基估计器(要校准的分类器),然后在第k个左外折叠上装配校准器。测试的结果预测将是k个安装校准器(“集合”)的平均值如果
ensemple=False
,将使用cross_val_predict
的单个配合来安装校准器考虑到这一点:
找到最佳的超参数,然后是的,使用相同的序列数据集,但使用所选的cv策略(集合真或假),以适合校准器。再次注意,您永远不会在同一数据上安装分类器和calibrartor
有趣的是,根据分类器和数据的大小,校准可能有助于提高概率预测的准确性,也可能没有:
相关问题 更多 >
编程相关推荐