Skip to content

Instantly share code, notes, and snippets.

@vanessaaleung
Last active September 28, 2019 18:49
Show Gist options
  • Save vanessaaleung/93956a83bbf60eea7fa7bab4bc31131e to your computer and use it in GitHub Desktop.
Save vanessaaleung/93956a83bbf60eea7fa7bab4bc31131e to your computer and use it in GitHub Desktop.
from sklearn.cluster import KMeans
# set number of clusters
kclusters = 5
sf_grouped_clustering = sf_grouped.drop('Neighborhood', 1)
# run k-means clustering
kmeans = KMeans(n_clusters = kclusters, random_state = 0).fit(sf_grouped_clustering)
# check cluster labels generated for each row in the dataframe
kmeans.labels_[0:10]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment