To measure the performance of a regression model, we can calculate the distance from predicted output and the actual output as a quantifier of the performance of the model. Here, we often use the Root Mean Square Error (RMSE), Relative Square Error (RSE), and R-Square as common measurements. In the following recipe, we will illustrate how to compute these measurements from a built regression model.
In this recipe, we will use the Quartet
dataset, which contains four regression datasets as our input data source.
Perform the following steps to measure the performance of the regression model:
- Load the
Quartet
dataset from thecar
package:
> library(car)
> data(Quartet)
- Plot the attribute,
y3
, againstx
using thelm
function:
> plot(Quartet$x, Quartet$y3) > lmfit = lm(Quartet$y3~Quartet$x) > abline(lmfit, col="red")
The linear regression plot
- You can retrieve predicted...