ROC-AUC 图呈肘形

ROC-AUC plot is in elbow shape

我想为我的逻辑回归模型创建一条 ROC 曲线,但我当前的代码没有给我传统的或期望的结果。下面是代码:-

over3 <- SMOTE(pol ~., data = train, perc.under = 150)
over3

set.seed(645)
logit_model4 <- glm(pol ~., data = over3, family = "binomial")
logit_model4
summary(logit_model4)

fitted.results4 <- predict(logit_model4, test, type = "response")
fitted.results4

fitted.results4 <- ifelse(fitted.results4 > 0.5, 1, 0)
fitted.results4

table(test$pol, fitted.results4)

library(pROC)

pim <- roc(response = test$pol, predictor = fitted.results3, partial.auc = c(100,90),
    partial.auc.correct = T, percent = T)
plot(pim)

结果图如下:-

但是,我希望绘图的输出采用传统方式,即:-

希望有人能帮帮我

不要对结果进行二分法!

fitted.results4 <- ifelse(fitted.results4 > 0.5, 1, 0)

通过评估每个可能的阈值来构建 ROC 曲线。通过对结果进行二分法,可以防止这种情况发生。

相反,您应该直接使用定量预测概率:

fitted.results4 <- predict(logit_model4, test, type = "response")
library(pROC)
pim <- roc(response = test$pol, predictor = fitted.results4, partial.auc = c(100,90), partial.auc.correct = T, percent = T)
plot(pim)