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

Inspecting the data

Before you get started with setting up a model, it is always a good idea to have a look at the data. We did this earlier for the town map example, so let's continue our streak. Using Matplotlib, we create a scatter plot where the color of each data point corresponds to the class label:

In [10]: plt.scatter(data[:, 0], data[:, 1], c=target,  
cmap=plt.cm.Paired, s=100)

... plt.xlabel(iris.feature_names[0])
... plt.ylabel(iris.feature_names[1])
Out[10]: <matplotlib.text.Text at 0x23bb5e03eb8>

To make plotting easier, we limit ourselves to the first two features (iris.feature_names[0] being the sepal length and iris.feature_names[1] being the sepal width). We can see a nice separation of classes in the following figure:

Plotting the first two features of the Iris dataset
主站蜘蛛池模板: 依兰县| 吉木乃县| 宜良县| 吉木乃县| 贞丰县| 临沧市| 孝感市| 高青县| 两当县| 广水市| 墨江| 古蔺县| 磐石市| 陆河县| 泊头市| 邵东县| 霍林郭勒市| 崇礼县| 长岛县| 南投县| 石台县| 团风县| 资中县| 西林县| 贵州省| 山阴县| 镇宁| 绥化市| 遂川县| 尼木县| 西安市| 民勤县| 勐海县| 米林县| 华蓥市| 兴仁县| 岳阳市| 金华市| 恭城| 扎囊县| 封开县|