Comparing models with the housing dataset
Let’s start by loading and preparing the data for modeling:
- Set up the Python environment: Start by making a copy of the code from Chapter 4 and modifying it. Like in Chapter 4, we’ll need the pandas and NumPy libraries. We’ve chosen to name the file
housingvaluemodelcomparison.ipynb
:# ---------------------------------------- # filename housingvaluemodelcomparison.ipynb # purpose compare predictions of house value # by different models # author Joyce Weiner # revision 1.0 # revision history 1.0 - initial script # ---------------------------------------- import pandas as pd import numpy as np
- Load the California housing dataset from scikit-learn: The housing dataset is built into scikit-learn. The
fetch_california_housing
function has two useful parameters that allow you to load the data as a pandas DataFrame and put the features (X
values) and the targety
value into separate variables in just one line of code...