我正在尝试计算二进制(0,1)与决策树预测的目标变量的 ROC。
当我将预测值设置为二进制时,它给了我以下错误:
> roc(as.numeric(pred),as.numeric(data$target))
Setting levels: control = 0, case = 1
Setting direction: controls < cases
当我将预测值设置为概率时,它给了我以下错误:
> roc(pred[,2],as.numeric(data$target))
'response' has more than two levels. Consider setting 'levels'
explicitly or using 'multiclass.roc' insteadSetting levels:
control = 0.166666666666667, case = 0.232876712328767
Setting direction: controls < cases
所以我很困惑我应该为预测设置什么格式以便正确计算 ROC?为什么我的函数显示这些错误?