问题描述:
使用sklearn的brier_score_loss类计算四分类的布里尔分数时报错:
ValueError: Only binary classification is supported. The type of the target is multiclass
新版sklearn的brier_score_loss不支持多分类了
解决方案:
先对测试集的标签进行哑变量变换:
proba= models.predict_proba(Xtest)
Ytest_= Ytest.copy()
Ytest_ = pd.get_dummies(Ytest_)
再计算每个类别的布里尔分数,就可以成功计算出来
from sklearn.metrics import brier_score_loss as BS
for i in range(4):
bs = BS(Ytest_[i],proba[:,i])

当使用新版sklearn计算四分类的布里尔分数时遇到错误:`ValueError: Only binary classification is supported. The type of the target is multiclass.` 通过将标签进行哑变量变换,然后分别计算每个类别的布里尔分数可以解决此问题。具体步骤包括对测试集标签进行哑变量处理,然后利用`brier_score_loss`计算每个类别得分。
41

被折叠的 条评论
为什么被折叠?



