Another measurement is by using the ROC curve (this requires the ROCR
package), which plots a curve according to its true positive rate against its false positive rate. This recipe will introduce how we can use the ROC curve to measure the performance of the prediction model.
Before applying the ROC curve to assess the prediction model, first be sure that the generated training set, testing dataset, and built prediction model, ctree.predict
, are within the R session.
Perform the following steps to assess prediction performance:
Prepare the probability matrix:
> train.ctree.pred = predict(train.ctree, testset) > train.ctree.prob = 1- unlist(treeresponse(train.ctree, testset), use.names=F)[seq(1,nrow(testset)*2,2)]
Install and load the
ROCR
package:> install.packages("ROCR") > require(ROCR)
Create an
ROCR
prediction object from probabilities:> train.ctree.prob.rocr = prediction(train.ctree.prob, testset$Survived...