You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Im trying to make my algorithm, which involves KMeans, reproducible, but even If I set random_state value I always get different inertia values.
I'm using this page dataset without the first line (dataset size).
Steps/Code to Reproduce
from sklearn.cluster import KMeans
import numpy as np
points = np.genfromtxt('page.txt')
for l in range(10):
kmeans = KMeans(n_clusters=30, n_init=1, random_state=42)
kmeans.fit(points)
centroids = kmeans.cluster_centers_
print('{0:.20f}'.format(kmeans.inertia_))
The relative difference between these inertiae is less than machine precision (~2e-16). It may be due to rounding errors being different due to the multi-threaded aspect of inertia computation. However, the clustering should be the same, i.e. centers and labels should be the same. I checked with your example on my machine and it's the case.
Describe the bug
Im trying to make my algorithm, which involves KMeans, reproducible, but even If I set random_state value I always get different inertia values.
I'm using this page dataset without the first line (dataset size).
Steps/Code to Reproduce
Expected Results
I expect to get printed ten time the same value
Actual Results
1008436173.14048004150390625000
1008436173.14048004150390625000
1008436173.14047992229461669922
1008436173.14048004150390625000
1008436173.14047992229461669922
1008436173.14048004150390625000
1008436173.14047992229461669922
1008436173.14048004150390625000
1008436173.14048004150390625000
1008436173.14048004150390625000
Versions
The text was updated successfully, but these errors were encountered: