1. Learn
  2. /
  3. Courses
  4. /
  5. Practicing Machine Learning Interview Questions in Python

Exercise

K-means clustering

In a machine learning interview setting, you might be asked how the output from K-means clustering might be used to assess its performance as the best algorithm.

In this exercise you'll practice K-means clustering. Using the .inertia_ attribute to compare models with different numbers of clusters, k, you'll then also use this information to assess cluster number in the next exercise.

Recall that the target variable in the diabetes dataset is progression.

Where you are in the pipeline:

Machine learning pipeline

Instructions 1/4

undefined XP
  • 1
    • Create a feature matrix X by dropping the target variable progression and fit the data to the instantiated k-means object.
  • 2
    • Instantiate a 5 cluster k-means and print its inertia.
  • 3
    • Fit the feature matrix to a 10-cluster k-means and print its inertia.
  • 4
    • Fit the feature matrix to a 20-cluster k-means and print its inertia.