Skip to content

Instantly share code, notes, and snippets.

@karamanbk
Created May 3, 2019 20:07
Show Gist options
  • Save karamanbk/ec8526800ff475419ee9054484400d21 to your computer and use it in GitHub Desktop.
Save karamanbk/ec8526800ff475419ee9054484400d21 to your computer and use it in GitHub Desktop.
#k-means
kmeans = KMeans(n_clusters=4)
kmeans.fit(tx_user[['Frequency']])
tx_user['FrequencyCluster'] = kmeans.predict(tx_user[['Frequency']])
#order the frequency cluster
tx_user = order_cluster('FrequencyCluster', 'Frequency',tx_user,True)
#see details of each cluster
tx_user.groupby('FrequencyCluster')['Frequency'].describe()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment