3-12 数据加载和简单的数据探索

2018-07-21  本文已影响0人  SRFHolmes
import numpy as np
import matplotlib as mpl
import matplotlib.pyplot as plt
from sklearn import datasets
iris = datasets.load_iris()
iris.keys()
'''
dict_keys(['data', 'target', 'target_names', 'DESCR', 'feature_names'])
'''

print(iris.DESCR)
#print 格式化

iris.data
iris.data.shape
#(150, 4)

iris.feature_names
#data中四列表示的含义  
'''
['sepal length (cm)',
 'sepal width (cm)',
 'petal length (cm)',
 'petal width (cm)']
'''

iris.target
iris.target.shape
#(150,)
#data中150行的类型
iris.target_names
'''
array(['setosa', 'versicolor', 'virginica'], dtype='<U10')
'''

plt.scatter(X[:,0],X[:,1])
plt.show()

#分颜色
y=iris.target
colo=["cyan","yellow","blue"]
mark=["o","+","x"]
for i in range(3):
    plt.scatter(X[y==i,0],X[y==i,1],color=colo[i],marker=mark[i])
plt.show()
上一篇下一篇

猜你喜欢

热点阅读