官术网_书友最值得收藏!

Loading the dataset

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

In [1]: import numpy as np
... from sklearn import datasets
... from sklearn import metrics
... from sklearn import model_selection as modsel
... from sklearn import linear_model
... %matplotlib inline
... import matplotlib.pyplot as plt
... plt.style.use('ggplot')

Then, loading the dataset is a one-liner:

In [2]: 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', find all data in 'data', all feature names in 'feature_names', and all target values in 'target':

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

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

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

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

In [5]: boston.target.shape
Out[5]: (506,)
主站蜘蛛池模板: 花莲市| 巴青县| 辽宁省| 漯河市| 台前县| 辽阳市| 故城县| 荃湾区| 汤阴县| 昭平县| 淳化县| 扎赉特旗| 收藏| 常山县| 古交市| 绥滨县| 孟连| 师宗县| 榆中县| 丰顺县| 林西县| 宽城| 饶平县| 平定县| 沁源县| 固镇县| 吐鲁番市| 泸水县| 蒙自县| 汶上县| 寻乌县| 宝鸡市| 繁峙县| 北宁市| 河北省| 通城县| 临城县| 犍为县| 那曲县| 峡江县| 瑞安市|