Skip to Content
Learn
K-Means Clustering
Visualize After K-Means

We have done the following using sklearn library:

  • Load the embedded dataset
  • Compute K-Means on the dataset (where k is 3)
  • Predict the labels of the data samples

And the labels resulted in either 0, 1, or 2.

Let’s finish it by making a scatter plot of the data again!

This time, however, use the labels numbers as the colors.

To edit colors of the scatter plot, we can set c = labels:

plt.scatter(x, y, c=labels, alpha=0.5) plt.xlabel('sepal length (cm)') plt.ylabel('sepal width (cm)')

Instructions

1.

Create an array called x that contains the Column 0 of samples.

Create an array called y that contains the Column 1 of samples.

2.

Make a scatter plot of x and y, using labels to define the colors.

Folder Icon

Sign up to start coding

Already have an account?