Defining the number of clusters (K)

PHOTO EMBED

Tue May 21 2024 08:56:03 GMT+0000 (Coordinated Universal Time)

Saved by @Uncoverit #python

# 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
content_copyCOPY