Loading the dataset

We can again thank scikit-learn for easy access to the dataset. We first import all of the necessary modules, as we did earlier:

In [14]: from sklearn import datasets
... from sklearn import metrics

Then loading the dataset is a one-liner:

In [15]: boston = datasets.load_boston()

The structure of the boston object is identical to the iris object, as discussed in the preceding command. We can get more information about the dataset in 'DESCR' and find all data in 'data', all feature names in 'feature_names', the physical location of the Boston CSV dataset in 'filename', and all target values in 'target':

In [16]: dir(boston)
Out[16]: ['DESCR', 'data', 'feature_names', 'filename', 'target']

The dataset contains a total of 506 data points, each of which has 13 features:

In [17]: boston.data.shape
Out[17]: (506, 13)

Of course, we have only a single target value, which is the housing price:

In [18]: boston.target.shape
Out[18]: (506,)
..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
18.188.178.181