कितने डॉमिनेंट रंग?
हमने matplotlib की image क्लास के imread() फंक्शन से नीचे दी गई इमेज लोड की है.

RGB वैल्यूज़ एक DataFrame batman_df में स्टोर हैं. इन RGB वैल्यूज़ को whiten() फंक्शन से स्टैंडर्डाइज़ किया गया है, और वे scaled_red, scaled_blue और scaled_green कॉलम्स में हैं.
इस DataFrame के साथ एक elbow plot बनाइए. कितने डॉमिनेंट रंग मौजूद हैं?
यह अभ्यास पाठ्यक्रम का हिस्सा है
Python में क्लस्टर विश्लेषण
अभ्यास निर्देश
num_clustersकी हर वैल्यू परkmeans()फंक्शन चलाकर distortions की एक लिस्ट बनाएँ.- लिस्ट्स
num_clustersऔरdistortionsके साथ एक DataFrameelbow_plotबनाएँ. seabornकी.lineplot()मेथड से प्लॉट बनाइए, जिसमें x-axis परnum_clustersऔर y-axis परdistortionsहों.
इंटरैक्टिव व्यावहारिक अभ्यास
इस अभ्यास को इस नमूना कोड को पूरा करके आज़माएँ।
distortions = []
num_clusters = range(1, 7)
# Create a list of distortions from the kmeans function
for i in ____:
cluster_centers, distortion = ____
distortions.append(____)
# Create a DataFrame with two lists, num_clusters and distortions
elbow_plot = pd.DataFrame(____)
# Create a line plot of num_clusters and distortions
sns.lineplot(x=____, y=____, data = elbow_plot)
plt.xticks(num_clusters)
plt.show()