
I am unable to run KMeans() in my Jupyter Notebook. The same piece of code works correctly if I just use it in a Python script. I have already installed KMeans/Sklearn using.
!pip3 install KMeans
Then what's the issue?
The above two cells are not yet executed.
Please re-run all the cells. Probably you've restarted the kernel and forgot to run the cells where you've imported the KMeans from sklearn.cluster.
Straightforward answer: Write in a cell of the Jupyter notebook (in In[6] for example:
from sklearn.cluster import KMean
km=KMean(1)
And see if there is an error.
Long answer You have different cells in the Jupyter notebook. You need to execute all the cells if you have restarted Jupyter Notebook.
On your screenshots: It is written In[] in the two first pieces of code, and In[6] in the piece of code where you got the error. That might mean that you did not execute the two first cells (In[]) before the third (In[6]), thus the Kmean had not been imported.
What you can do: - Ensure you have executed the two first pieces of code ? - Ensure you did not clear the variables before executing In[6]? (not sure if this function exists on Jupyter)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With