ROC_func | R Documentation |
This is a general utility function, not part of the bsnsing functionality.
ROC_func( df, label_colnum, score_colnum, pos.label = "1", plot.ROC = F, add_on = F, color = "black", lty = 1 )
df |
a data frame which must contain at least these two columns: the prediction scores (numeric values, not necessarily be between 0 and 1) and the true class labels. |
label_colnum |
the column index of the scores column in df |
score_colnum |
the column index of the true class labels column in df |
pos.label |
a character string matching the positive class label used in the class labels column |
plot.ROC |
a logical value indicating whether the ROC curve should be plotted |
add_on |
a logical value indicating whether the ROC curve should be added to an existing plot |
color |
a character string specifying the color of the ROC curve in the plot |
lty |
line type used in the plot (1 solid, 2 dashed, etc.) |
the area under the curve (AUC) value
## Not run: n <- nrow(BreastCancer) trainset <- sample(1:n, 0.7*n) # randomly sample 70\ testset <- setdiff(1:n, trainset) # the remaining is for testing # Build a tree to predict Class, using all default options bs <- bsnsing(Class~., data = BreastCancer[trainset,]) summary(bs) # display the tree structure pred <- predict(bs, BreastCancer[testset,], type='class') actual <- BreastCancer[testset, 'Class'] table(pred, actual) # display the confusion matrix # Plot the ROC curve and display the AUC ROC_func(data.frame(predict(bs, BreastCancer[testset,]), BreastCancer[testset,'Class']), 2, 1, pos.label = 'malignant', plot.ROC=TRUE) # Plot the tree to PDF and generate the .tex file plot(bs, file='../bsnsing_test/fig/BreastCancer.pdf') ## End(Not run)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.