Code Monkey home page Code Monkey logo

movie-recommendations's Introduction

Movie Recommendations

A recommender system is one that seeks to predict the "rating" or "preference" a user would give to an item.

Methods

Cosine Similarity Notebook

Since the one-hot representation of movies is too sparse, we can create a dense representation using Principal Component Analysis. On this dense representation, we can recommend similar movies using cosine similarity metric.

Truncated SVD Notebook

In this method, we create representations of both, movies and users by considering the top-n factors from their Singular Value Decompositions. Next, using the (movie, user) representaion pairs we can train a regression model to predict the corresponding rating value.

Restricted Boltzmann Machines Notebook

The Restricted Boltzmann Machine (RBM) is a special type of artificial neural network. Here, the RBM is trained using the Contrastive Divergence loss function to estimate the distribution of ratings given the movie ratings of a user.

SVD Matrix Factorisation Notebook

This method involves embedding movies in a vector space by using a stochastic estimation of Matrix Factorisation. The movie embedding can be considered a representation of the movie features and we can make recommendations using a similarity metric.

Probabilistic Matrix Factorization Repository

A Bayesian approach to factorizing the Ratings matrix using Variational Inference. As a result, each rating prediction is a Gaussian with its variance representing uncertainty.

Miscellaneous

  • Movie Sentiment : Analysing a movie review's text to determine whether it is positive or negative. Find the repository here.

  • Anime Finder : A cosine similarity based anime recommendation engine along with a web-based interface. Find the repository here.

  • Book Recommendations : An experiment using the Truncated SVD method to recommend books. Find the notebook here.

movie-recommendations's People

Contributors

saurabhmathur96 avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

movie-recommendations's Issues

IndexError: only integers, slices (`:`), ellipsis (`...`), numpy.newaxis (`None`) and integer or boolean arrays are valid indices

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))

A problem about the RBM based recommendation

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?

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.