简体   繁体   中英

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

使用来自https://pypi.python.org/pypi/pip 的PIP 安装程序

pip install -U scikit-learn

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

(in Windows7 64bit) As Maxim says you can try Anaconda. (its faster!!!) It worked for me(updating Anaconda) with a similar problem(DLL import failed/ no module named svm)

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM