muricoca / crab

Crab is a flexible, fast recommender engine for Python that integrates classic information filtering recommendation algorithms in the world of scientific Python packages (numpy, scipy, matplotlib).
http://muricoca.github.com/crab
Other
1.18k stars 376 forks source link

ImportError: No module named learn.base #105

Open JayForest opened 9 years ago

JayForest commented 9 years ago

hi,I start to learn to study the crab using python ,but I come across some problems, my example's code is

author = 'Cookie' from scikits.crab import datasets movies = datasets.load_sample_movies() songs = datasets.load_sample_songs()

print(movies.data)

print(songs) from scikits.crab.models import MatrixPreferenceDataModel

Build the model

model = MatrixPreferenceDataModel(movies.data) from scikits.crab.metrics import pearson_correlation from scikits.crab.similarities import UserSimilarity

Build the similarity

similarity = UserSimilarity(model, pearson_correlation)

from scikits.crab.recommenders.knn import UserBasedRecommender

problems: Traceback (most recent call last): File "D:/Rail/jx/Python/project1/Crab.py", line 16, in from scikits.crab.recommenders.knn import UserBasedRecommender File "D:\Program Files (x86)\Python27\lib\site-packages\scikits\crab\recommenders\knninit.py", line 1, in from .classes import ItemBasedRecommender, UserBasedRecommender File "D:\Program Files (x86)\Python27\lib\site-packages\scikits\crab\recommenders\knn\classes.py", line 17, in from base import ItemRecommender, UserRecommender File "D:\Program Files (x86)\Python27\lib\site-packages\scikits\crab\recommenders\knn\base.py", line 17, in from ..base import MemoryBasedRecommender File "D:\Program Files (x86)\Python27\lib\site-packages\scikits\crab\recommenders\base.py", line 17, in from ..base import BaseRecommender File "D:\Program Files (x86)\Python27\lib\site-packages\scikits\crab\base.py", line 11, in from scikits.learn.base import BaseEstimator ImportError: No module named learn.base

I had installed the packages:Python 2.7.9, numpy-MKL-1.8.0.win-amd64-py2.7,scipy-0.15.1-cp27-none-win_amd64,matplotlib-1.4.3.win-amd64-py2.7,scikit-learn-0.16.1.win-amd64-py2.7,thank you very much.

JoannaMisztalRadecka commented 9 years ago

I had the same problem, but I fixed it after installing scikits-learn on Ubuntu according to instructions from http://scikit-learn.org/stable/install.html, I had to change the import from:

from scikits.learn.base import BaseEstimator

to:

from sklearn.base import BaseEstimator

psneog commented 9 years ago

I am facing the same problem on windows. Somebody help me please.

Lawrence-Liu commented 9 years ago

@IIUJ-JoannaMisztal is right about this. This project is toooooo old, back then scikit-learn was called scikits.learn. So you need to update the code and recompile it yourself.

psneog commented 9 years ago

I have installed the canopy python distribution and the program started working!

HuihuangZhang commented 9 years ago

According to Installing Crab, you should install scikits.learn. However, from scikit-learn_doc

Warning As of version 0.9 (released in September 2011), the import path for scikit-learn has changed from scikits.learn to sklearn

so maybe the author should update the source code!

GizemEce commented 8 years ago

Hello, I tried all the things you listed but i am still getting error while i am importing "from crab.recommenders.knn import UserBasedRecommender". And 3 months ago i correct it as " from scikits.crab.recommenders.knn.classes import UserBasedRecommender" and it worked but now it does not work? Does anyone have problems with it currently and know how to fix it?

Izzy4me commented 8 years ago

So... anyone has an experience what i really needs to refactor for newest version of scikits to work properly? Or i should use the old one? I know project is old, but my tutor adviced it for my, to do simply recomendation system module and now it is not funny -.-

imqianyi commented 8 years ago
  1. install pip install -U scikit-learn.
  2. fix the code scikits.learn.base to sklearn.base
rmf770609 commented 8 years ago

Hi, I’ve changed “scikits.learn.base” to “sklearn.base” both @ scikits/crab/base.py @ scikits/crab/metrics/classes.py

And I still got problem with “from scikits.crab.recommenders.knn import UserBasedRecommender” by ImportError: No module named base

Is there anything I did wrong?

DerekAI commented 8 years ago

I have made following change in the source code:

from scikits.learn.base import BaseEstimator

from sklearn.base import BaseEstimator

then reinstall crab using the following command in crab directory

python setup.py install

Now, it seems to be more health.

finlay-liu commented 8 years ago

I find it can clone the source code and install by source code. It will be ok.

benadaba commented 8 years ago

This did the trick for me: http://datapandas.com/index.php/2016/08/21/importerror-no-module-named-learn-base-crab-python-fix/