Session Ready
Exercise

Calculate and plot sum of squared errors

Now, you will calculate the sum of squared errors for different number of clusters ranging from 1 to 10.

You will use the normalized RFMT data that you created in the previous exercise, it is stored as datamart_rfmt_normalized. The KMeans module from scikit-learn is also imported. Also, we have initialized an empty dictionary to store sum of squared errors as sse = {}.

Feel free to explore the date in the console.

Instructions
100 XP
  • Initialize KMeans with k clusters and random state 1 and fit KMeans on the normalized dataset.
  • Assign sum of squared distances to k element of sse dictionary.
  • Add the plot title "The Elbow Method", X-axis label "k", and Y-axis label "SSE".
  • Plot SSE values for each k stored as keys in the dictionary.