concept quality in category R

This is an excerpt from Manning's book Practical Data Science with R, Second Edition.
There are other measures of accuracy and other measures of the quality of a model, as well. We’ll talk about model evaluation in chapter 6.
Before publicly sharing predictions, you want to inspect both the predictions and model for quality. We recommend plotting the actual y (in this case, predicted income) that you’re trying to predict as if it were a function of your prediction. In this case, plot log10(PINCP) as if it were a function of predLogPINCP. If the predictions are very good, then the plot will be dots arranged near the line y=x, which we call the line of perfect prediction (the phrase is not standard terminology; we use it to make talking about the graph easier). The steps to produce this, illustrated in figure 7.6, are shown in the next listing.
Recall that the residuals are the errors in prediction: log10(dtrain$PINCP) - predict (model,newdata=dtrain). In linear regression, the residuals are everything. Most of what you want to know about the quality of your model fit is in the residuals. You can calculate useful summaries of the residuals for both the training and test sets, as shown in the following listing.
Listing 11.1. R-annotated Markdown
--- #1 title: "Buzz scoring example" output: github_document --- ```{r, include = FALSE} #2 # process document with knitr or rmarkdown. # knitr::knit("Buzz_score_example.Rmd") # creates Buzz_score_example.md # rmarkdown::render("Buzz_score_example.Rmd", # rmarkdown::html_document()) # creates Buzz_score_example.html ``` #3 Example scoring (making predictions with) the Buzz data set. #4 First attach the `randomForest` package and load the model and test data. ```{r} #5 suppressPackageStartupMessages(library("randomForest")) lst <- readRDS("thRS500.RDS") varslist <- lst$varslist fmodel <- lst$fmodel buzztest <- lst$buzztest rm(list = "lst") ``` Now show the quality of our model on held-out test data. #6 ```{r} #7 buzztest$prediction <- predict(fmodel, newdata = buzztest, type = "prob")[, 2, drop = TRUE] WVPlots::ROCPlot(buzztest, "prediction", "buzz", 1, "ROC curve estimating quality of model predictions on held- out data") ```