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

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
主站蜘蛛池模板: 神农架林区| 华蓥市| 新野县| 乐都县| 日喀则市| 蓝田县| 江津市| 方城县| 闸北区| 二手房| 定安县| 柳林县| 始兴县| 清徐县| 禄丰县| 鄂尔多斯市| 南溪县| 江华| 新兴县| 云南省| 仙居县| 崇阳县| 宁强县| 霸州市| 松溪县| 韶关市| 抚松县| 勃利县| 那坡县| 赤壁市| 阜新市| 曲周县| 巨鹿县| 策勒县| 剑河县| 麟游县| 京山县| 安远县| 辽中县| 津南区| 勐海县|