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]:
from scikits.crab import datasets
movies = datasets.load_sample_movies()
songs = datasets.load_sample_songs()
import pprint ## to make printed items clearer
pprint.pprint(movies.data)
pprint.pprint(movies.user_ids)
pprint.pprint(movies.item_ids)
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 sklearn.base import BaseEstimator
from scikits.crab.recommenders.knn import UserBasedRecommender
#build the user Based recommender
recommender = UserBasedRecommender(model, similarity, with_preference=True)
#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.