require(randomForest) rf.pred<-predict(fit, valid, type="prob") > rf.pred[1:20, ] 0 1 16 0.0000 1.0000 23 0.3158 0.6842 43 0.3030 0.6970 52 0.0886 0.9114 55 0.1216 0.8784 75 0.0920 0.9080 82 0.4332 0.5668 120 0.2302 0.7698 128 0.1336 0.8664 147 0.4272 0.5728 148 0.0490 0.9510 153 0.0556 0.9444 161 0.0760 0.9240 162 0.4564 0.5436 172 0.5148 0.4852 176 0.1730 0.8270 215 0.0100 0.9900 222 0.0104 0.9896 255 0.1358 0.8642 267 0.1000 0.9000 > rf.pred<-predict(fit, valid, type="prob") > > rf.roc <- prediction(rf.pred[,2], valid[,32]) > rf.auc <- performance(rf.roc, 'tpr', 'fpr') > plot(rf.auc)
Dear R community, I am plot the ROC curve for randomforest result, I am not sure the above code is right or not? I just used the second column of the probabilities, the pr(outcome=1). Can anyone give some comments? **************************** someguys use the following codes to plot, but I can not use the treeresponse commad in randomforest object directly. # create model using random forest and bagging ensemble using conditional inference trees 035 x.cf <- cforest(Class ~ ., data=BreastCancer[ind == 1,], control = cforest_unbiased(mtry = ncol(BreastCancer)-2)) 036 x.cf.pred <- predict(x.cf, newdata=BreastCancer[ind == 2,]) 037 x.cf.prob <- 1- unlist(treeresponse(x.cf, BreastCancer[ind == 2,]), use.names=F)[seq(1,nrow(BreastCancer[ind == 2,])*2,2)] 038 -- Sincerely, Changbin -- Changbin Du DOE Joint Genome Institute Bldg 400 Rm 457 2800 Mitchell Dr Walnut Creet, CA 94598 Phone: 925-927-2856 [[alternative HTML version deleted]] ______________________________________________ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.