rasbt / python-machine-learning-book

The "Python Machine Learning (1st edition)" book code repository and info resource
MIT License
12.18k stars 4.39k forks source link

Plotting iris data in Ch02 assumes that the data is in a particular order #41

Closed medakk closed 7 years ago

medakk commented 7 years ago

In chapter 2, where the iris data is plotted on a scatterplot,

# extract sepal length and petal length
X = df.iloc[0:100, [0, 2]].values

# plot data
plt.scatter(X[:50, 0], X[:50, 1],
            color='red', marker='o', label='setosa')
plt.scatter(X[50:100, 0], X[50:100, 1],
            color='blue', marker='x', label='versicolor')

it is simply assumed that the first 50 rows belong to the label setosa, and the next 50 to versicolor. The scatterplot should be generated using the labels(which are in the 5th column of the dataset)

medakk commented 7 years ago

Oops, I hadn't got to the part of the book where you had defined the plot_decision_regions function. Sorry.

Closing.