Impact of seeds on distinct clusters
You noticed the impact of seeds on a dataset that did not have well-defined groups of clusters. In this exercise, you will explore whether seeds impact the clusters in the Comic Con data, where the clusters are well-defined.
The data is stored in a pandas DataFrame, comic_con
. x_scaled
and y_scaled
are the column names of the standardized X and Y coordinates of people at a given point in time.
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.
# Import random class
____
# Initialize seed
random.____(____)
# Run kmeans clustering
cluster_centers, distortion = kmeans(comic_con[['x_scaled', 'y_scaled']], 2)
comic_con['cluster_labels'], distortion_list = vq(comic_con[['x_scaled', 'y_scaled']], cluster_centers)
# Plot the scatterplot
sns.scatterplot(x='x_scaled', y='y_scaled',
hue='cluster_labels', data = comic_con)
plt.show()