Python में क्लस्टर विश्लेषण
Shaumik Daityari
Business Analyst
kmeans(obs, k_or_guess, iter, thresh, check_finite)
obs: standardized observationsk_or_guess: क्लस्टर्स की संख्याiter: iterations की संख्या (डिफॉल्ट: 20)thres: threshold (डिफॉल्ट: 1e-05)check_finite: क्या observations में केवल finite numbers हैं, यह जाँचे (डिफॉल्ट: True)दो ऑब्जेक्ट लौटाता है: cluster centers, distortion

vq(obs, code_book, check_finite=True)
obs: standardized observationscode_book: cluster centerscheck_finite: क्या observations में केवल finite numbers हैं, यह जाँचे (डिफॉल्ट: True)दो ऑब्जेक्ट लौटाता है: cluster labels की list, distortions की list
kmeans एक single distortion value लौटाता हैvq distortions की एक list लौटाता है.# Import kmeans and vq functions
from scipy.cluster.vq import kmeans, vq
# Generate cluster centers and labels
cluster_centers, _ = kmeans(df[['scaled_x', 'scaled_y']], 3)
df['cluster_labels'], _ = vq(df[['scaled_x', 'scaled_y']], cluster_centers)
# Plot clusters
sns.scatterplot(x='scaled_x', y='scaled_y', hue='cluster_labels', data=df)
plt.show()

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