Resolved: kmeans.inertia_ gives 0 and got different list based on code in the lecture
when calculating .inertia_ it gives 0.0 and wcss list I got is [3.5, 0.5, 0.0, 0.0, 0.0, 0.0] which is completely different from the lecture. And Pyhton gives me below message. Could you please explain it?
/usr/local/lib/python3.10/dist-packages/sklearn/cluster/_kmeans.py:870: FutureWarning: The default value of `n_init` will change from 10 to 'auto' in 1.4. Set the value of `n_init` explicitly to suppress the warning warnings.warn( /usr/local/lib/python3.10/dist-packages/sklearn/cluster/_kmeans.py:870: FutureWarning: The default value of `n_init` will change from 10 to 'auto' in 1.4. Set the value of `n_init` explicitly to suppress the warning warnings.warn( /usr/local/lib/python3.10/dist-packages/sklearn/cluster/_kmeans.py:870: FutureWarning: The default value of `n_init` will change from 10 to 'auto' in 1.4. Set the value of `n_init` explicitly to suppress the warning warnings.warn( /usr/local/lib/python3.10/dist-packages/sklearn/cluster/_kmeans.py:870: FutureWarning: The default value of `n_init` will change from 10 to 'auto' in 1.4. Set the value of `n_init` explicitly to suppress the warning warnings.warn( <ipython-input-28-22d2b048c4b9>:5: ConvergenceWarning: Number of distinct clusters (3) found smaller than n_clusters (4). Possibly due to duplicate points in X. kmeans.fit(x) /usr/local/lib/python3.10/dist-packages/sklearn/cluster/_kmeans.py:870: FutureWarning: The default value of `n_init` will change from 10 to 'auto' in 1.4. Set the value of `n_init` explicitly to suppress the warning warnings.warn( <ipython-input-28-22d2b048c4b9>:5: ConvergenceWarning: Number of distinct clusters (3) found smaller than n_clusters (5). Possibly due to duplicate points in X. kmeans.fit(x) /usr/local/lib/python3.10/dist-packages/sklearn/cluster/_kmeans.py:870: FutureWarning: The default value of `n_init` will change from 10 to 'auto' in 1.4. Set the value of `n_init` explicitly to suppress the warning warnings.warn( <ipython-input-28-22d2b048c4b9>:5: ConvergenceWarning: Number of distinct clusters (3) found smaller than n_clusters (6). Possibly due to duplicate points in X. kmeans.fit(x)
Hey Rugiyya,
Thank you for reaching out!
As the warning reads, to suppress it, you need to specify the value of the n_init
parameter explicitly. Change the following line of code:
kmeans = KMeans(1)
to, for example, the following:
kmeans = KMeans(n_clusters = 1, n_init = 10)
Let me know if the issue persists.
Kind regards,
365 Hristina
just error message was removed, but still getting the same results.
Hey again Rugiyya,
Have you made sure you've imported the relevat database?
Try downloading the resources attached to this lecture (Jupyter Notebook and data source) and run the Jupyter Notebook provided by the instructor (making sure you apply the changes we've discussed above).
Do you obtain the same results as before or do you retrieve the ones from the lecture? Let me know.
Kind regards,
365 Hristina
Thanks Hristina, now resolved! :)