Run silhouette analysis and select the optimum n_clusters 1 from sklearn.cluster import KMeans 2 from sklearn.metrics im

Business, Finance, Economics, Accounting, Operations Management, Computer Science, Electrical Engineering, Mechanical Engineering, Civil Engineering, Chemical Engineering, Algebra, Precalculus, Statistics and Probabilty, Advanced Math, Physics, Chemistry, Biology, Nursing, Psychology, Certifications, Tests, Prep, and more.
Post Reply
answerhappygod
Site Admin
Posts: 899604
Joined: Mon Aug 02, 2021 8:13 am

Run silhouette analysis and select the optimum n_clusters 1 from sklearn.cluster import KMeans 2 from sklearn.metrics im

Post by answerhappygod »

Run Silhouette Analysis And Select The Optimum N Clusters 1 From Sklearn Cluster Import Kmeans 2 From Sklearn Metrics Im 1
Run Silhouette Analysis And Select The Optimum N Clusters 1 From Sklearn Cluster Import Kmeans 2 From Sklearn Metrics Im 1 (41.84 KiB) Viewed 64 times
how can i fix ?
Run silhouette analysis and select the optimum n_clusters 1 from sklearn.cluster import KMeans 2 from sklearn.metrics import silhouette_score 3 range_n_clusters = [2, 3, 4, 5, 6, 7, 8, 9, 10] 4 optimum_n_clusters = 0 5 max_silhouette_score = 0 6 for n_clusters in range_n_clusters: 7 kmeans = KMeans(n_clusters = n_clusters) 8 kmeans.fit(x_pca) silhouette score = silhouette score(x_pca, kmeans. labels 10 if silhouette_score > max_silhouette_score: 11 max_silhouette_score = silhouette_score 12 optimum a clusters = n clusters 13 9 TypeError Traceback (most recent call last) <ipython-input-46-975c7ffa69f2> in <module>() 7 kmeans = KMeans (n_clusters = n_clusters) 8 kmeans.fit(x_pca) 9 silhouette_score = silhouette_score(x_pca, kmeans. labels_) 10 if silhouette_score > max_silhouette_score: 11 max_silhouette_score = silhouette_score TypeError: 'numpy. float64' object is not callable SEARCH STACK OVERFLOW
Join a community of subject matter experts. Register for FREE to view solutions, replies, and use search function. Request answer by replying!
Post Reply