1. Learn
  2. /
  3. Courses
  4. /
  5. Cluster Analysis in Python

Connected

Exercise

How many dominant colors?

We have loaded the following image using the imread() function of the image class of matplotlib.

The RGB values are stored in a DataFrame, batman_df. The RGB values have been standardized used the whiten() function, stored in columns, scaled_red, scaled_blue and scaled_green.

Construct an elbow plot with the DataFrame. How many dominant colors are present?

Instructions

100 XP
  • Create a list of distortions based on each value in num_clusters by running the kmeans() function.
  • Create a DataFrame elbow_plot with the lists: num_clusters and distortions.
  • Plot the data with seaborn's .lineplot() method with num_clusters on the x-axis and distortions on the y-axis.