# 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
Preview:
downloadDownload PNG
downloadDownload JPEG
downloadDownload SVG
Tip: You can change the style, width & colours of the snippet with the inspect tool before clicking Download!
Click to optimize width for Twitter