In this recipe, we'll look at how well our regression fits the underlying data. We fit a regression in the last recipe, but didn't pay much attention to how well we actually did it. The first question after we fit the model was clearly "How well does the model fit?" In this recipe, we'll examine this question.
Let's use the
lr object and
boston dataset—reach back into your code from the Fitting a line through data recipe. The
lr object will have a lot of useful methods now that the model has been fit.
There are some very simple metrics and plots we'll want to look at as well. Let's take another look at the residual plot from the last chapter:
>>> import matplotlib.pyplot as plt