1

Hi I'm trying to follow the machine learning 101 tutorial provided by sklearn, and I keep running into an error.

I have the most the sklearn version downloaded from here: https://github.com/scikit-learn/scikit-learn

I run Windows

python: 2.7.5 (32bit)

scipy: .12

numpy: 1.7.0

When I run

from sklearn.linear_model import LinearRegression
model = LinearRegression()

I get

---------------------------------------------------------------------------
ImportError                               Traceback (most recent call last)
<ipython-input-7-9f5ae92552bb> in <module>()
----> 1 from sklearn.linear_model import LinearRegression
      2 model = LinearRegression()

C:\WinPython-32bit-2.7.5.1\python-2.7.5\lib\site-packages\sklearn\linear_model\__init__.py in <module>()
     10 # complete documentation.
     11 
---> 12 from .base import LinearRegression
     13 
     14 from .bayes import BayesianRidge, ARDRegression

C:\WinPython-32bit-2.7.5.1\python-2.7.5\lib\site-packages\sklearn\linear_model\base.py in <module>()
     28 from ..utils.sparsefuncs import (csc_mean_variance_axis0,
     29                                  inplace_csc_column_scale)
---> 30 from .cd_fast import sparse_std
     31 
     32 

ImportError: No module named cd_fast

And based on this: https://github.com/scikit-learn/scikit-learn/issues/1202

It might be an error with blas? But that's in scipy, and I had problems with that earlier, but I just updated scipy and it should be fine.

Please help! Thanks in advance

4

2 回答 2

3

你忘了编译。python setup.py install在源目录中运行,或python setup.py build_ext --inplace,或获取二进制分发。

(很多 scikit-learn 实际上是用 Cython、C 或 C++ 实现的。你需要 C 和 C++ 编译器从源代码安装它。)

于 2013-06-27T16:11:53.597 回答
0

从不同的问题复制粘贴答案:如果您使用来自http://www.lfd.uci.edu/~gohlke/pythonlibs/#scikit-learn的二进制文件。如下载页面所示,它们需要 numpy-MKL。官方的 numpy 二进制文件不起作用。

于 2016-05-03T10:40:58.570 回答