TAGS :Viewed: 22 - Published at: a few seconds ago

[ How do I install Sklearn for Reinteract? ]

I want to use Reinteract to develop a machine-learning application. I'd like to use Sklearn's svm module, but when I run

import sklearn.svm

I get

File "C:\Python27\lib\site-packages\sklearn\svm__init__.py", line 13, in from .classes import SVC, NuSVC, SVR, NuSVR, OneClassSVM, LinearSVC File "C:\Python27\lib\site-packages\sklearn\svm\classes.py", line 1, in from .base import BaseLibLinear, BaseSVC, BaseLibSVM File "C:\Python27\lib\site-packages\sklearn\svm\base.py", line 2, in import scipy.sparse as sp ImportError: No module named sparse

Similarly, when I run

import sklearn.cluster

I get

File "C:\Python27\lib\site-packages\sklearn\cluster__init__.py", line 6, in from .spectral import spectral_clustering, SpectralClustering File "C:\Python27\lib\site-packages\sklearn\cluster\spectral.py", line 11, in from ..base import BaseEstimator, ClusterMixin File "C:\Python27\lib\site-packages\sklearn\base.py", line 10, in from scipy import sparse ImportError: cannot import name sparse

I am able to run

import sklearn

without error.

Reinteract on my Windows 7 machine is using

  • sys.version = 2.7.5 (default, May 15 2013, 22:43:36) [MSC v.1500 32 bit (Intel)]
  • numpy.version.version = 1.6.1
  • scipy.version.version = 0.12.0

Answer 1


use PIP installer from https://pypi.python.org/pypi/pip

pip install -U scikit-learn

Answer 2


Raphael, if you're on Windows i highly recommend a prepackaged install, like

PythonXY https://code.google.com/p/pythonxy/

Anaconda http://www.continuum.io/downloads (this works on Mac/Linux also)

or WinPython https://code.google.com/p/winpython/

the sklearn "stack" comes nicely packaged in all of them