【发布时间】:2017-05-22 21:00:44
【问题描述】:
我想计算 Roc 曲线,然后从线性判别模型计算 AUC。你知道我该怎么做吗?这里有代码:
##LDA
require(MASS)
library(MASS)
lda.fit = lda(Negative ~., trainSparse)
lda.fit
plot(lda.fit)
###prediction on the test set
lda.pred=predict(lda.fit,testSparse)
table(testSparse$Negative,lda.pred$class)
【问题讨论】:
-
@calimo 我试过这个代码:> rocplot = function(pred, truth, ...){ + predob = prediction(pred, truth) + perf = performance(predob, "tpr", " fpr") + plot(perf, ...) + } > yhat.opt = predict(lda.fit,testSparse, decision.values = TRUE) > fit.opt = attributes(yhat.opt)$decision.values > par (mfrow = c(1, 2)) > rocplot(fitted.opt,testSparse["Negative"], main = "Training Data"),但随后出现此错误:预测错误(pred,truth):格式预测无效。
标签: r machine-learning lda roc auc