# Defining the number of clusters (K) num_clusters = 4 # Initialising and fitting the KMeans model kmeans = KMeans(n_clusters = num_clusters, n_init = 10) cluster_labels = kmeans.fit_predict(dim_ds) df_trimmed['ClustersK'] = cluster_labels
# Defining the number of clusters (K) num_clusters = 4 # Initialising and fitting the KMeans model kmeans = KMeans(n_clusters = num_clusters, n_init = 10) cluster_labels = kmeans.fit_predict(dim_ds) df_trimmed['ClustersK'] = cluster_labels