Skip to content

Instantly share code, notes, and snippets.

@andrea-dagostino
Created November 22, 2021 23:57
Show Gist options
  • Save andrea-dagostino/df1d751b85295a0783473233851f84d8 to your computer and use it in GitHub Desktop.
Save andrea-dagostino/df1d751b85295a0783473233851f84d8 to your computer and use it in GitHub Desktop.
posts/raggruppamento-testuale-con-tf-idf
from sklearn.cluster import KMeans
# inizializziamo il kmeans con 3 centroidi
kmeans = KMeans(n_clusters=3, random_state=42)
# addestriamo il modello
kmeans.fit(X)
# salviamo i gruppi di ogni punto
clusters = kmeans.labels_
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment