Elbow method
The silhouette score and elbow methods provide validation to the results you see from each. In a machine learning interview setting, you may get asked about one or the other but discussing the specifics of one in the context of the other would contribute greatly to your answer.
In this exercise, for each k
value, you will initialize a K-means model and use the inertia_
attribute to identify the sum of squared distances of samples to the nearest cluster center that, when plotted, appears to be an 'elbow' in the plot.
Recall in the last lesson that as the value of k
increased, the value for inertia_
decreased.
Already imported for you are matplotlib.pyplot
as plt
and KMeans
from sklearn.cluster
. The feature matrix X
has also been created for you.
Diese Übung ist Teil des Kurses
Practicing Machine Learning Interview Questions in Python
Interaktive Übung
Versuche dich an dieser Übung, indem du diesen Beispielcode vervollständigst.
# Create empty list
sum_of_squared_distances = ____