Created
December 15, 2019 21:37
-
-
Save Perishleaf/8a7fa7b877ff078b3e93fbf4614fa195 to your computer and use it in GitHub Desktop.
Classification using K-mean cluster
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# set number of clusters | |
kclusters = 4 | |
sydney_grouped_clustering = sydney_grouped.drop('Suburb', 1) | |
# run k-means clustering | |
kmeans = KMeans(n_clusters=kclusters, random_state=0).fit(sydney_grouped_clustering) | |
# check cluster labels generated for each row in the dataframe | |
kmeans.labels_[0:10] | |
sydney_merged.loc[sydney_merged['Cluster Labels'] == 2, sydney_merged.columns[[0] + list(range(4, sydney_merged.shape[1]))]] |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment