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

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,)
主站蜘蛛池模板: 洛阳市| 清原| 泗水县| 监利县| 普兰店市| 青阳县| 郸城县| 揭阳市| 肃北| 安泽县| 漯河市| 会同县| 兴文县| 许昌市| 新蔡县| 陆川县| 石棉县| 涪陵区| 石泉县| 乌兰浩特市| 凤城市| 麻江县| 晋宁县| 洪泽县| 阿拉善左旗| 兴义市| 南华县| 长乐市| 沁阳市| 徐闻县| 当涂县| 铁岭县| 漠河县| 宁乡县| 平远县| 鄄城县| 长兴县| 凌源市| 海淀区| 谢通门县| 呼图壁县|