Skip to content

Instantly share code, notes, and snippets.

@ogrisel
Created July 14, 2018 16:29
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ogrisel/5cdf1aedf3dddc94dd82270ab40f91f1 to your computer and use it in GitHub Desktop.
Save ogrisel/5cdf1aedf3dddc94dd82270ab40f91f1 to your computer and use it in GitHub Desktop.
from sklearn.datasets import make_blobs
from sklearn.cluster import KMeans
from sklearn.externals import joblib
m = joblib.Memory(cachedir='/tmp/joblib')
make_blobs = m.cache(make_blobs)
data, labels = make_blobs(n_samples=10**5, n_features=50, cluster_std=100,
centers=10, random_state=777)
max_it = 100
cl = KMeans(n_clusters=10, algorithm='full', max_iter=max_it, tol=0)
cl.fit(data)
print(cl.n_iter_)
assert cl.n_iter_ == max_it
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment