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
Run silhouette analysis and select the optimum n_clusters 1 from sklearn.cluster import KMeans 2 from sklearn.metrics im
-
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
Join a community of subject matter experts. Register for FREE to view solutions, replies, and use search function. Request answer by replying!