Regression-房价预测-(2/4)-读入并查看数据特征
2017-05-07 本文已影响0人
_藏九_
这是Regression-房价预测的第(2)篇笔记。介绍outline里的:
- Load data
- Data exploration-Statistical, visualization
1. Load data
首先读入数据。这里是csv数据,直接用pandas.read_csv()读入就可以了。
import pandas as pd
data = pd.read_csv('housing.csv')
2. Data exploration-Statistical, visualization
2.1 Statiscial features
首先看看有多少数据点(489,4)。
data.shape
数据类型

接下来看看它们到底长什么样。这里'MEDV'是y,需要分离出来。

查看统计特征

2.2 Visualization
单变量特征图
data.hist()

data.plot(kind='density', subplots=True, layout=(1,4), sharex=False, legend=False, fontsize=1)

多变量特征图
from matplotlib import pyplot
fig = pyplot.figure()
ax = fig.add_subplot(111)
cax = ax.matshow(data.corr(), vmin=-1, vmax=1, interpolation='none')
fig.colorbar(cax)
pyplot.show()

END