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

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,)
主站蜘蛛池模板: 万州区| 巴林左旗| 类乌齐县| 莎车县| 茂名市| 台北县| 怀化市| 正定县| 宝鸡市| 安康市| 姜堰市| 竹北市| 乐昌市| 隆德县| 西畴县| 灌云县| 镇巴县| 卢氏县| 凤庆县| 秀山| 陇川县| 铜鼓县| 墨脱县| 阳原县| 凤凰县| 通山县| 十堰市| 浦县| 留坝县| 平山县| 泰来县| 原平市| 夏津县| 夹江县| 靖边县| 房山区| 永昌县| 南投市| 亚东县| 汽车| 济宁市|