Skip to content

Instantly share code, notes, and snippets.

@Bennykillua
Last active July 2, 2022 09:08
Show Gist options
  • Save Bennykillua/f2328a2e2be0c33445cb72dac05bb3ae to your computer and use it in GitHub Desktop.
Save Bennykillua/f2328a2e2be0c33445cb72dac05bb3ae to your computer and use it in GitHub Desktop.
Sklearn Open Source
from sklearn import cluster, datasets
# load data
iris = datasets.load_iris()
# K-means clustering: create clusters for k=3
k=3
k_means = cluster.KMeans(k)
# fit data
k_means.fit(iris.data)
# print results
print( k_means.labels_[::10])
print( iris.target[::10])
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment