gpt4 book ai didi

ROC 曲线看起来不正确

转载 作者:行者123 更新时间:2023-11-30 09:36:25 27 4
gpt4 key购买 nike

我已经使用 ROCR 包绘制了 2 类问题的 ROC 曲线。根据我的理解,至少对于较小的数据集,曲线应该看起来像阶跃变化图。我的输入实际上很小,但我得到的曲线基本上看起来是直线。是因为 PROC 适合一条穿过曲线的线还是我遗漏了其他东西?

输入在这里click me代码如下,ROC部分在最后。感谢您的帮助!

library("caret")
library("ROCR")
sensor6data_s10_2class <- read.csv("/home/sensei/clustering/sensor6data_f21_s10_with2Labels.csv")
sensor6data_s10_2class <- within(sensor6data_s10_2class, Class <- as.factor(Class))
sensor6data_s10_2class$Class2 <- relevel(sensor6data_s10_2class$Class,ref="1")

set.seed("4321")
inTrain_s10_2class <- createDataPartition(y = sensor6data_s10_2class$Class, p = .75, list = FALSE)
training_s10_2class <- sensor6data_s10_2class[inTrain_s10_2class,]
testing_s10_2class <- sensor6data_s10_2class[-inTrain_s10_2class,]
y_s10 <- testing_s10_2class[,22]

ctrl_s10_2class <- trainControl(method = "repeatedcv", number = 10, repeats = 10 , savePredictions = TRUE)
model_train_multinom_s10_2class <- train(Class2 ~ ZCR + Energy + SpectralC + SpectralS + SpectralE + SpectralF + SpectralR + MFCC1 + MFCC2 + MFCC3 + MFCC4 + MFCC5 + MFCC6 + MFCC7 + MFCC8 + MFCC9 + MFCC10 + MFCC11 + MFCC12 + MFCC13, data = training_s10_2class, method="multinom", trControl = ctrl_s10_2class)
pred_multinom_s10_2class = predict(model_train_multinom_s10_2class, newdata=testing_s10_2class)

pred2_s10 <- prediction(as.numeric(as.character(pred_multinom_s10_2class)), as.numeric(as.character(y_s10)))
perf2_s10 <- performance(pred2_s10, "tpr", "fpr")
plot(perf2_s10,col='magenta',lwd=3)

最佳答案

您应该预测类概率而不是类标签。试试这个:

pred_multinom_s10_2class = predict(model_train_multinom_s10_2class, newdata=testing_s10_2class, type='prob')

pred2_s10 <- prediction(pred_multinom_s10_2class[,1], as.numeric(as.character(y_s10)))
perf2_s10 <- performance(pred2_s10, "tpr", "fpr")
plot(perf2_s10,col='magenta',lwd=3)

enter image description here

关于ROC 曲线看起来不正确,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/40799824/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com