2

I am reading Machine Learning in action Chapter Two, I don't know how to label the dots which are separated into three group.

The data has four columns and two columns in the first three are being used as x and y, the last column is the label (1 , 2 and 3).

Dataset is in the same numpy array and is plot with different color and size with .scatter(X, Y, 15 * the value of label, 15 * the value of label)

Graph with Label in the book Here is the code for plotting without legend.

fig = plt.figure()
ax = fig.add_subplot(111)
ax.scatter(datingDataMat[:, 0], datingDataMat[:, 1], 15 * np.array(datingLabels), 15 * np.array(datingLabels))
fig.suptitle('Figure 2 Using X = Colume 0 and Y = Colume 1')
plt.xlabel('Frequent Flyier Miles Earned Per Year')
plt.ylabel('Percentage of Time Spent Playing Video Games')

plt.show()
Max
  • 35
  • 5
  • It's not the same. The data are coming from the same array and plot with different size in the same scatter. I want to ask how to achieve different label of this. – Max Apr 26 '18 at 19:30

0 Answers0