14. Model Diagnostics
14.1 Introduction
Building models is a continuous art. As we start adding and removing variables from our models, we need a means to compare models with one another and a consistent way of measuring model performance. There are many ways we can compare models, and this chapter describes some of these methods.
14.2 Residuals
The residuals of a model compare what the model calculates and the actual values in the data. Let’s fit some models on a housing data set.
import pandas as pd housing = pd.read_csv('../data/housing_renamed.csv')
print(housing.head())
neighborhood type units year_built sq_ft income \ 0 FINANCIAL R9-CONDOMINIUM 42 1920.0 36500 1332615 ...
Get Pandas for Everyone: Python Data Analysis, First Edition 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.