Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
403 views
in Technique[技术] by (71.8m points)

r - ROC plot and axis wrong, randomForest model

I have the below data and I would like to know if I am on the right tracks regarding a random forest model

I run the following randomForest model but when I go to plot the ROC my axis looks off and I believe it could be something to do with my model but cannot find where I have gone wrong. The x-axis starts at 1.0 and not 0....

ROC Curve

fit <- randomForest(as.factor(status) ~ CA.TA + CA.CL + EBIT.TA + CF.TL + WC.TA + WC.S + TL.TA + C.TA,
                    data = train,
                    importance = TRUE,
                    #type = "prob",
                    ntree = 200)

prediction <- NULL
prediction$status_prediction <- as.data.frame(predict(fit, test))
prediction$status_prediction_prob <- predict(fit, test, type = "prob")

prediction <- NULL
prediction$status_prediction <- predict(fit, test)
prediction <- as.data.frame(prediction)
prediction$status_prediction_prob <- predict(fit, test, type = "prob")

library(caret)
confusionMatrix(prediction$status_prediction, test$status)


prediction$status_prediction <- as.numeric(prediction$status_prediction)
library(pROC)
result.roc <- roc(test$status, prediction$status_prediction)
plot(result.roc, print.thres="best", print.thres.best.method="closest.topleft", main = "ROC curve", print.auc = TRUE)
auc(test$status, prediction$status_prediction)
See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)
Waitting for answers

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...