saurabhmathur96 / movie-recommendations Goto Github PK
View Code? Open in Web Editor NEWRecommend movies to users by RBMs, TruncatedSVD, Stochastic SVD and Variational Inference
Recommend movies to users by RBMs, TruncatedSVD, Stochastic SVD and Variational Inference
Please see the error:
IndexError Traceback (most recent call last)
in ()
10
11 for movie_id in (10,100,1000):
---> 12 print(movie_id,predict_rating(similarities, user_ratings, movie_id))
in predict_rating(model, ratings, movie_id, n)
9
10 rated_movies = ratings.keys()
---> 11 similar_movies = model[movie_id, rated_movies].argsort()[:-1]
12 top_n = [ratings.keys()[i] for i in similar_movies[:n]]
13
IndexError: only integers, slices (:
), ellipsis (...
), numpy.newaxis (None
) and integer or boolean arrays are valid indices
------------------------------------------------------Cosine Similarity
import numpy as np
def predict_rating(model, ratings, movie_id, n=5):
# model = movie similarities matrix
# movie_id = target movie id
# ratings = dict of movie_id: rating
rated_movies = ratings.keys()
similar_movies = model[movie_id, rated_movies].argsort()[:-1]
top_n = [ratings.keys()[i] for i in similar_movies[:n]]
# Average rating weighted by similarity
scores = sum(model[movie_id, m] * ratings[m] for m in top_n)
prediction = float(scores) / sum(model[movie_id, m] for m in top_n)
return prediction
user_id = 10
movies_rated = np.where(R[user_id].todense() > 0)[1].tolist()
movie_ratings = R[user_id, movies_rated].todense().tolist()[0]
user_ratings = dict(zip(movies_rated, movie_ratings))
print('10 2.77208508312')
print('100 1.77135318293')
print('1000 2.35262213947')
for movie_id in (10,100,1000):
print(movie_id,predict_rating(similarities, user_ratings, movie_id))
In your implementation of RBM based CF, I see you directly fed the rating data in, ratings ranges from 1-5. I think this should corresponds to Guassian visible layer because the data is not binary, which is different from the original implementation of Ruslan and Hinton. However, your reconstruction, v_2 seems to be binary...
This confused me because I think in RBM, v_2 should try to reconstruct the input data, so I don't know why real input but binary reconstruction works. Can you give some explanation about this?
CF-NADE is the current state-of-the-art. It was developed by Yin Zheng et. al. at Hulu Research. It leverages deep learning to make recommendations.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.