March 2019
Beginner to intermediate
464 pages
10h 57m
English
Now that we have a machine learning model that is trained to predict the 3 month customer value, let's discuss how to evaluate the performance of this model. As discussed previously, we are going to use R2, MAE, and a scatter plot of predicted versus actual to evaluate our model. We first need to get the prediction output from our model, like the following code:
train_preds <- predict(regFit, train)test_preds <- predict(regFit, test)
We are going to use the miscTools package to compute the in-sample and out-of-sample R2 values. Take a look at the following code:
# R-squared# install.packages('miscTools')library(miscTools)inSampleR2 <- rSquared(train$CLV_3_Month, resid=train$CLV_3_Month - train_preds) ...Read now
Unlock full access