- Machine Learning for OpenCV
- Michael Beyeler
- 167字
- 2021-07-02 19:47:24
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,)
推薦閱讀
- Data Visualization with D3 4.x Cookbook(Second Edition)
- Mobile Application Development:JavaScript Frameworks
- Java應用開發與實踐
- Learning Python Design Patterns(Second Edition)
- Unity 2017 Mobile Game Development
- Frank Kane's Taming Big Data with Apache Spark and Python
- 用案例學Java Web整合開發
- Visual Basic程序設計習題與上機實踐
- 零基礎學Python編程(少兒趣味版)
- Solutions Architect's Handbook
- 深入理解BootLoader
- Python+Office:輕松實現Python辦公自動化
- Mobile Forensics:Advanced Investigative Strategies
- Python預測分析實戰
- UML基礎與Rose建模實用教程(第三版)