Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
我使用插入符号库来计算二元分类问题的类概率和预测,使用 10 倍交叉验证和 5 次重复。
现在我有TRUE(每个数据点的观察值)值、PREDICTED(通过算法)值、0 类概率和1 类概率,算法使用这些概率来预测类标签。
现在我如何roc使用ROCR或者pROC库创建一个对象然后计算auc值?
roc
ROCR
pROC
auc
假设我将所有这些值都存储在数据框中predictions。例如predictions$pred和predictions$obs分别是预测值和真实值,依此类推...
predictions
predictions$pred
predictions$obs
由于您没有提供可重现的示例,我假设您有一个二元分类问题,并且您预测Class是Good或Bad。
Class
Good
Bad
predictions <- predict(object=model, test[,predictors], type='prob')
你可以做:
> pROC::roc(ifelse(test[,"Class"] == "Good", 1, 0), predictions[[2]])$auc # Area under the curve: 0.8905