Billy
Billy

Reputation: 11

Item Prediction from recommender system

I have the similarity that I get from pairwise in python library for item based CF. Then I use this prediction from Implementing your own recommender systems in Python.

pred = ratings.dot(similarity) / np.array([np.abs(similarity).sum(axis=1)])

but I get bad rating prediction. The rating prediction are around 0.1 - 0.9. Is this pred calculation is valid?

Upvotes: 1

Views: 972

Answers (1)

Timothy Tan
Timothy Tan

Reputation: 45

The problem lies in the way mean user ratings are calculated in the prediction function.

Calling mean on the ratings array includes all the 0 values which represents movies not rated by the user.

You will want to create the array of ratings by performing the mean function only on the ratings rated by the user. This can be performed by a simple groupby operation on the train data

mean_user_rating = train_data.groupby('user_id')['rating'].mean()

Upvotes: 1

Related Questions