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

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
主站蜘蛛池模板: 江口县| 淳安县| 田阳县| 桃源县| 兴山县| 上栗县| 乌拉特前旗| 柳州市| 清远市| 哈密市| 永靖县| 京山县| 大连市| 泸定县| 巴南区| 营山县| 韶山市| 常德市| 新密市| 东阳市| 蓬溪县| 广汉市| 晋州市| 津市市| 东方市| 新巴尔虎左旗| 玛曲县| 阿荣旗| 祁东县| 洛扎县| 嘉义县| 温州市| 德庆县| 墨脱县| 南皮县| 安溪县| 平定县| 东丽区| 隆林| 伊宁市| 毕节市|