July 2019
Beginner to intermediate
740 pages
16h 52m
English
Whenever we work with linear regression, we should visualize our residuals, or the discrepancies between the actual values and the model's predictions; as we learned in Chapter 7, Financial Analysis – Bitcoin and the Stock Market, they should be centered around zero and homoskedastic (similar variance throughout). We can use a kernel density estimate to assess whether the residuals are centered around zero and a scatter plot to see if they are homoskedastic.
Let's look at the utility function in ml_utils.regression, which will create these subplots for checking the residuals:
import matplotlib.pyplot as pltimport numpy as npdef plot_residuals(y_test, preds): """ Plot residuals to evaluate regression. Parameters: - y_test: ...
Read now
Unlock full access