Log in from a computer to take this course

You'll need to log in from a computer to start Learn the Basics of Machine Learning. But you can practice or keep up your coding streak with the Codecademy Go app. Download the app to get started.

apple storegoogle store

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)')



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

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


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

Sign up to start coding

Mini Info Outline Icon
By signing up for Codecademy, you agree to Codecademy's Terms of Service & Privacy Policy.

Or sign up using:

Already have an account?