Session Ready
Exercise

How many clusters of grain?

In the video, you learned how to choose a good number of clusters for a dataset using the k-means inertia graph. You are given an array samples containing the measurements (such as area, perimeter, length, and several others) of samples of grain. What's a good number of clusters in this case?

KMeans and PyPlot (plt) have already been imported for you.

This dataset was sourced from the UCI Machine Learning Repository.

Instructions
100 XP
  • For each of the given values of k, perform the following steps:
  • Create a KMeans instance called model with k clusters.
  • Fit the model to the grain data samples.
  • Append the value of the inertia_ attribute of model to the list inertias.
  • The code to plot ks vs inertias has been written for you, so hit 'Submit Answer' to see the plot!