कितने क्लस्टर?

Python में क्लस्टर विश्लेषण

Shaumik Daityari

Business Analyst

सही k कैसे चुनें?

  • k-means क्लस्टरिंग में सही क्लस्टर संख्या (k) ढूँढने का कोई पूर्ण तरीका नहीं है
  • Elbow method

Python में क्लस्टर विश्लेषण

Distortion पर फिर नज़र

  • Distortion: बिंदुओं की क्लस्टर सेंटर्स से स्क्वेयर्ड दूरी का योग
  • क्लस्टर संख्या बढ़ने पर घटता है
  • जब क्लस्टर संख्या बिंदुओं के बराबर हो जाए तो शून्य हो जाता है
  • Elbow plot: क्लस्टर सेंटर्स और distortion के बीच लाइन प्लॉट

Python में क्लस्टर विश्लेषण

Elbow method

  • Elbow plot: क्लस्टर संख्या और distortion का प्लॉट
  • Elbow plot से डेटा में मौजूद क्लस्टरों की संख्या का संकेत मिलता है
Python में क्लस्टर विश्लेषण

Python में Elbow method

# Declaring variables for use
distortions = []

num_clusters = range(2, 7)
# Populating distortions for various clusters
for i in num_clusters:
    centroids, distortion = kmeans(df[['scaled_x', 'scaled_y']], i)
    distortions.append(distortion)
# Plotting elbow plot data
elbow_plot_data = pd.DataFrame({'num_clusters': num_clusters,
                                'distortions': distortions})

sns.lineplot(x='num_clusters', y='distortions', 
             data = elbow_plot_data)
plt.show()
Python में क्लस्टर विश्लेषण

Python में क्लस्टर विश्लेषण

Elbow method पर अंतिम बातें

  • यह केवल optimal k (क्लस्टरों की संख्या) का संकेत देता है
  • हमेशा यह नहीं बताता कि k (क्लस्टरों की संख्या) कितनी है
  • अन्य तरीके: average silhouette और gap statistic
Python में क्लस्टर विश्लेषण

आगे: अभ्यास

Python में क्लस्टर विश्लेषण

Preparing Video For Download...