Evaluating the trained model

We now need to measure the performance of our model to see if we really have any power to predict Sales using TV as in independent variable. To do this, we can load in our test set, make predictions using our trained model for each test example, and then calculate one of the evaluation metrics discussed in Chapter 3, Evaluation and Validation.

For this problem, let's use the Mean Absolute Error (MAE) as our evaluation metric. This seems reasonable, because it results in something directly comparable with our Sales values and we do not have to be too worried about outliers or extreme values.

To calculate the predicted Sales values using our trained regression.Regression value, we just need to parse the values in ...

Get Machine Learning With Go now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.