How to use silhouette score in k-means clustering from sklearn library?
问题 I'd like to use silhouette score in my script, to automatically compute number of clusters in k-means clustering from sklearn. import numpy as np import pandas as pd import csv from sklearn.cluster import KMeans from sklearn.metrics import silhouette_score filename = "CSV_BIG.csv" # Read the CSV file with the Pandas lib. path_dir = ".\\" dataframe = pd.read_csv(path_dir + filename, encoding = "utf-8", sep = ';' ) # "ISO-8859-1") df = dataframe.copy(deep=True) #Use silhouette score range_n