I am trying to run Skikit learn through Spyder on Anaconda
C:\Anaconda3>conda --version
conda 4.3.4
C:\Anaconda3>python --version
Python 3.5.2 :: Anaconda 4.0.0 (64-bit)
Spyder 2.3.8
I try to do the following:
print("Scikit-Learn", sklearn.__version__)
NameError: name 'sklearn' is not defined
from sklearn.model_selection import *
from ..utils.fixes import rankdata
ImportError: cannot import name 'rankdata'
Errors
Any idea why this error is coming as in Anaconda it shows the package as present but when I run through Spyder it gives the above error.
As you are using anaconda try:
conda update scikit-learn
Conda will try to handle de dependences and it may update other packages.
If this does not work, in the file fixes.py located in <Anaconda_basedir>\lib\python3.5\site-packages\sklearn\utils there is a line if sp_version < (0,13, 0): which conditions the import of rankdata if the version of scipy is lower than 0.13.0.
For som reason, if the version is > 0.13.0 it should use the rankdata from scipy.stats. But, at least in my case it wasn't, what I did was to add a and False so it gets the rankdata from scipy.
The final line is:
...
if sp_version < (0, 13, 0) and False:
def rankdata(a, method='average'):
...