Crab Recommender System – Framework in Python Example and installation Problem Fix
This is just to show that the import errors which were encountered during the installation of Crab, a Recommender Framework in Python worked fine with the fixes I earlier outlined.
These were the errors and how they were fixed:
The code below is the example of how the Crab Recommender Works as outlined by Crab:
In [3]:
1 |
from scikits.crab import datasets |
1 |
movies = datasets.load_sample_movies() |
1 |
songs = datasets.load_sample_songs() |
1 2 |
import pprint ## to make printed items clearer pprint.pprint(movies.data) |
1 |
pprint.pprint(movies.user_ids) |
1 |
pprint.pprint(movies.item_ids) |
1 |
from scikits.crab.models import MatrixPreferenceDataModel |
1 2 |
#Build the model model = MatrixPreferenceDataModel(movies.data) |
1 |
from scikits.crab.metrics import pearson_correlation |
1 |
from scikits.crab.similarities import UserSimilarity |
1 2 |
#Build the similarity similarity = UserSimilarity(model, pearson_correlation) |
1 |
from sklearn.base import BaseEstimator |
1 |
from scikits.crab.recommenders.knn import UserBasedRecommender |
1 2 |
#build the user Based recommender recommender = UserBasedRecommender(model, similarity, with_preference=True) |
1 2 |
#recommend item for the user 5 (Toby) recommender.recommend(5) |
No module named : crab.recommenders.knn , any idea about that ?
Hi Soufiane,
just do a full import. hence instead of “from crab.recommenders.knn import UserBasedRecommender” put scikits infront of the crab. So it should be like this.
“from scikits.crab.recommenders.knn import UserBasedRecommender”
Let me know if that helps.