I am trying to do Kmeans with sklearn and I am getting weird error that says:
Traceback (most recent call last):
File "kmean_test.py", line 2, in <module>
from sklearn.cluster import KMeans
File "C:\Python\lib\site-packages\sklearn\cluster\__init__.py", line 6, in <module>
from .spectral import spectral_clustering, SpectralClustering
ModuleNotFoundError: No module named 'sklearn.cluster.spectral'
Working on Windows, I tried importing in Jupyter and just running a simple script from command.
I have tested my install of Scikit-Learn with the following imports and they work fine.
from sklearn import datasets
from sklearn import naive_bayes
First bit of code that i get the traceback error looks like:
import cv2, numpy as np
from sklearn.cluster import KMeans
def visualize_colors(cluster, centroids):
...
I got this import code
from sklearn.cluster import KMeans
from two tutorial sources but perhaps it is the problem? I have made attempts to import otherways but been unsuccessful
Just in case it was the sklearn install and because of reading through other stackoverflow suggestions I have:
I have tried uninstall and reinstall of numpy (with and without mkl), pandas, scikit-learn, and scipy both from regular command and admin command.
I have tried update as well.
I have downloaded the wheels and run install as administrator.
I am new. Please be kind. I am new to Windows development as well, Ugh! So if it has something to do with some complicated Windows system setup and software install etc etc I may not follow. I have spent 2 days trying to solve this one on my own and finally decided to reach out.
Thanks for any help!
UPDATE:
As per suggested below I have confirmed I do have the most recent version of sklearn 0.21.3
import sklearn
print(sklearn.__version__)
0.21.3
For the record here are my versions of the others:
python --version
Python 3.7.3
import numpy
numpy.version.version
'1.17.2'
import scipy
scipy.version.version
'1.3.1'
import pandas as pd
pd.__version__
'0.24.2'
Finally I would like to mention that I have been able to successfully apply Kmeans to my project without sklearn, however, I am trying to access the % and RGB values of the means. I have found two people showing how to do it and BOTH use sklearn. See here end comment by nathancy on why I am trying to install sklearn to do this specific thing: How to find the average colour of an image in Python with OpenCV?