Elbow method on uniform data
In the earlier exercise, you constructed an elbow plot on data with well-defined clusters. Let us now see how the elbow plot looks on a dataset with uniformly distributed points. You may want to display the data points before proceeding with the exercise.
The data is stored in a pandas DataFrame, uniform_data
. x_scaled
and y_scaled
are the column names of the standardized X and Y coordinates of points.
This exercise is part of the course
Cluster Analysis in Python
Hands-on interactive exercise
Have a go at this exercise by completing this sample code.
distortions = []
num_clusters = range(2, 7)
# Create a list of distortions from the kmeans function
for i in ____:
cluster_centers, distortion = ____
____.append(____)
# Create a DataFrame with two lists - number of clusters and distortions
elbow_plot = pd.DataFrame({'num_clusters': ____, 'distortions': ____})
# Creat a line plot of num_clusters and distortions
sns.____(x=____, y=____, data=____)
plt.xticks(num_clusters)
plt.show()