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

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
主站蜘蛛池模板: 扶绥县| 云龙县| 新乡县| 中宁县| 海口市| 清镇市| 阿尔山市| 万载县| 万安县| 于都县| 屏南县| 邛崃市| 宾川县| 宜阳县| 龙南县| 东丰县| 华安县| 东海县| 贵德县| 广南县| 怀宁县| 肃北| 江口县| 密山市| 建水县| 饶河县| 雷山县| 金乡县| 县级市| 盐津县| 穆棱市| 唐河县| 九龙城区| 长治市| 凌云县| 朝阳区| 筠连县| 邢台县| 渑池县| 南江县| 陆河县|