Skip to content

Instantly share code, notes, and snippets.

@jinglescode
Created March 6, 2020 14:19
Show Gist options
  • Save jinglescode/875bc783890e89236d445f74bf8ab696 to your computer and use it in GitHub Desktop.
Save jinglescode/875bc783890e89236d445f74bf8ab696 to your computer and use it in GitHub Desktop.
# KMeans
from sklearn.cluster import KMeans
kmeans = KMeans(n_clusters=int(num_days), random_state=0).fit(places_lat_long)
group = list(kmeans.labels_)
# MeanShift
from sklearn.cluster import MeanShift, estimate_bandwidth
bandwidth = estimate_bandwidth(places_lat_long, quantile=0.2)
clustering = MeanShift(bandwidth=bandwidth).fit(places_lat_long)
group = clustering.labels_
# SpectralClustering
from sklearn.cluster import SpectralClustering
clustering = SpectralClustering(n_clusters=9,
assign_labels="discretize",
random_state=0).fit(places_lat_long)
group = clustering.labels_
@YHR98
Copy link

YHR98 commented Mar 11, 2020

good job!

@jinglescode
Copy link
Author

good job!

Thanks @YHR98 😃

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment