NYC Data Science Academy| Blog
Bootcamps
Lifetime Job Support Available Financing Available
Bootcamps
Data Science with Machine Learning Flagship ๐Ÿ† Data Analytics Bootcamp Artificial Intelligence Bootcamp New Release ๐ŸŽ‰
Free Lesson
Intro to Data Science New Release ๐ŸŽ‰
Find Inspiration
Find Alumni with Similar Background
Job Outlook
Occupational Outlook Graduate Outcomes Must See ๐Ÿ”ฅ
Alumni
Success Stories Testimonials Alumni Directory Alumni Exclusive Study Program
Courses
View Bundled Courses
Financing Available
Bootcamp Prep Popular ๐Ÿ”ฅ Data Science Mastery Data Science Launchpad with Python View AI Courses Generative AI for Everyone New ๐ŸŽ‰ Generative AI for Finance New ๐ŸŽ‰ Generative AI for Marketing New ๐ŸŽ‰
Bundle Up
Learn More and Save More
Combination of data science courses.
View Data Science Courses
Beginner
Introductory Python
Intermediate
Data Science Python: Data Analysis and Visualization Popular ๐Ÿ”ฅ Data Science R: Data Analysis and Visualization
Advanced
Data Science Python: Machine Learning Popular ๐Ÿ”ฅ Data Science R: Machine Learning Designing and Implementing Production MLOps New ๐ŸŽ‰ Natural Language Processing for Production (NLP) New ๐ŸŽ‰
Find Inspiration
Get Course Recommendation Must Try ๐Ÿ’Ž An Ultimate Guide to Become a Data Scientist
For Companies
For Companies
Corporate Offerings Hiring Partners Candidate Portfolio Hire Our Graduates
Students Work
Students Work
All Posts Capstone Data Visualization Machine Learning Python Projects R Projects
Tutorials
About
About
About Us Accreditation Contact Us Join Us FAQ Webinars Subscription An Ultimate Guide to
Become a Data Scientist
    Login
NYC Data Science Acedemy
Bootcamps
Courses
Students Work
About
Bootcamps
Bootcamps
Data Science with Machine Learning Flagship
Data Analytics Bootcamp
Artificial Intelligence Bootcamp New Release ๐ŸŽ‰
Free Lessons
Intro to Data Science New Release ๐ŸŽ‰
Find Inspiration
Find Alumni with Similar Background
Job Outlook
Occupational Outlook
Graduate Outcomes Must See ๐Ÿ”ฅ
Alumni
Success Stories
Testimonials
Alumni Directory
Alumni Exclusive Study Program
Courses
Bundles
financing available
View All Bundles
Bootcamp Prep
Data Science Mastery
Data Science Launchpad with Python NEW!
View AI Courses
Generative AI for Everyone
Generative AI for Finance
Generative AI for Marketing
View Data Science Courses
View All Professional Development Courses
Beginner
Introductory Python
Intermediate
Python: Data Analysis and Visualization
R: Data Analysis and Visualization
Advanced
Python: Machine Learning
R: Machine Learning
Designing and Implementing Production MLOps
Natural Language Processing for Production (NLP)
For Companies
Corporate Offerings
Hiring Partners
Candidate Portfolio
Hire Our Graduates
Students Work
All Posts
Capstone
Data Visualization
Machine Learning
Python Projects
R Projects
About
Accreditation
About Us
Contact Us
Join Us
FAQ
Webinars
Subscription
An Ultimate Guide to Become a Data Scientist
Tutorials
Data Analytics
  • Learn Pandas
  • Learn NumPy
  • Learn SciPy
  • Learn Matplotlib
Machine Learning
  • Boosting
  • Random Forest
  • Linear Regression
  • Decision Tree
  • PCA
Interview by Companies
  • JPMC
  • Google
  • Facebook
Artificial Intelligence
  • Learn Generative AI
  • Learn ChatGPT-3.5
  • Learn ChatGPT-4
  • Learn Google Bard
Coding
  • Learn Python
  • Learn SQL
  • Learn MySQL
  • Learn NoSQL
  • Learn PySpark
  • Learn PyTorch
Interview Questions
  • Python Hard
  • R Easy
  • R Hard
  • SQL Easy
  • SQL Hard
  • Python Easy
Data Science Blog > APIs > Deep Learning Meets Recommendation Systems

Deep Learning Meets Recommendation Systems

Wann-Jiun Ma
Posted on Jan 24, 2017
Contributed by Wann-Jiun Ma. He attended the NYC Data Science Academy Online Data Science Bootcamp program. This post is based on his final capstone project and is finished in two weeks (part-time).

Introduction

Almost everyone loves to spend their leisure time to watch movies with their family and friends. We all have the same experience when we sit on our couch to choose a movie that we are going to watch and spend the next two hours but can't even find one after 20 minutes. It is so disappointing. We definitely need a computer agent to provide movie recommendation to us when we need to choose a movie and save our time. Apparently, a movie recommendation agent has already become an essential part of our life. According to Data Science Central "Although hard data is difficult to come by, many informed sources estimate that, for the major ecommerce platforms like Amazon and Netflix, that recommenders may be responsible for as much as 10% to 25% of incremental revenue." In this project, I study some basic recommendation algorithms for movie recommendation and also try to integrate deep learning to my movie recommendation system.

Movies are great examples of a combination of entertainment and visual art. Movie posters often can bring the ideas of movies to an audience directly and immediately. According to DesignMantic, "Post and pre-release of any movie their posters are the main elements which create the hype about them. More than half of the people (i.e., the target audience) decide whether to book tickets and watch the movie or not based on the movie posters." We can even predict any movie's mood by just looking at the typography of is poster. It sounds a bit like magic but it is definitely possible to predict a movie's genre by just looking at its poster. For myself, I know if I want to watch a movie or not by just looking at its poster. For example, since I am not a fan of cartoon movies, so whenever I saw those movie posters with cartoon themes or colors, I knew they are not my options. This decision process is very straightforward and dose not require any review reading (not sure people have time to read reviews). Therefore, in addition to some standard movie recommendation algorithms, I also use deep learning to process movie posters and try to find similar movies to be recommended to users. The goal is to mimic a human's visual ability and to build an intuitive movie recommender by just looking at movie posters based on deep learning. This project is inspired by Ethan Rosenthal's blog posts and I modified his codes in his blog posts to fit the algorithms used here.

We use the movie dataset downloaded from MovieLens website. The dataset consists of 100,000 ratings and 1,300 tag applications applied to 9,066 movies by 671 users. The dataset was last updated in 10/2016.

Inspired by student projects? Now it's your turn.
Get information about our data science programs and see how we can help you launch your data science career.



Collaborative Filtering

Roughly speaking, there are three types of recommendation systems (excluding simple ranking approach):

-- Content-based recommendation

-- Collaborative filtering

-- Hybrid models

For a content-based recommendation system, it is a regression problem in which we try to make a user-to-item rating prediction using the content of items as features.  On the other hand, for a collaborative filtering based recommendation system, we usually don't know the content of features in advance, and by using the similarity between different users (users may give similar ratings to the same items) and the similarity between items (similar movies may be given similar ratings by the users), we learn the latent features and make predictions on user-to-item ratings at the same time. Also, after we learn the features of the items, we can measure the similarity between items and recommend the most similar items to users based on their previous usage information. Content-based and collaborative filtering recommendation were the state of the art more than 10 years ago. Apparently, there are many different models and algorithms to improve the prediction performance. For example, for the case in which we don't have user-to-item rating information in advance, we can use the so-called implicit matrix factorization and replace the user-to-item ratings with some preference and confidence measures such as how many times the users click the corresponding items to perform collaborative filtering. Furthermore, we can also combine content-based and collaborative filtering methods to utilize content as "side information" to improve the prediction performance. This hybrid approach is usually implemented by "Learning to Rank" algorithm.

In this project, I focus on collaborative filtering based approach. First, I will discuss using item (user) similarity to make a user-to-item rating prediction without regression and also make a recommendation based on the item similarity. Then, I will discuss how to use regression to learn the latent features and make a recommendation simultaneously. After that, we will see how to use deep learning in a recommendation system.

Item Similarity

For collaborative filtering based recommendation system, the first building block is to construct the rating matrix in which each row represents a user and each column corresponds to the rating that this user gives to a particular movie. We build our rating matrix as follows:

where "ratings.csv" contains user id, movie id, rating, and time information, and "link.csv" contains movie id, IMDB id, and TMDB id. We combine these two tables since the IMDB id information is required for each movie to get the movie poster from The Movie Database website using its API. We examine the sparsity of our rating matrix as follows:

where the rating matrix is sparse with only 1.40% of non-zero entries. Now, let's split the rating matrix to two smaller matrices for the purpose of training and testing. We remove 10 ratings from the rating matrix and place them in the test set.

The (cosine) similarity among users/movies is calculated based on the following formula.

eq1

where, s(u,v) is just the cosine similarity measure between user u and user v.

Using the similarity among the users, we are able to make a prediction for each user-to-movie rating and also calculate the corresponding MSE of our user-to-movie rating prediction. The prediction is made by considering the ratings that a similar user gives. In particular, we can make a user-to-movie rating prediction based on the following formula.

eq3

where the prediction for user u to movie i is a weighted sum (normalized) of ratings that user v  gives to movie i with the similarity between user u and v as the weight.

The MSE we obtained is 9.8252 for our prediction. What does this number mean? Is it a good or bad recommendation? It is not very intuitive to evaluate our prediction performance by just looking at the MSE score. Therefore, let's evaluate the performance by checking the movie recommendation directly. We will query a movie of interest and ask our computer agent to recommend a few movies to us. The first thing to do is to get the corresponding movie posters so that we can see what the recommended movies are. We use the IMDB id numbers to get the movie posters from The Movie Database website using its API.

Now, it's fun time! let's see what our recommendation is. We will show four most similar movies along with the move we query. The movie we query is placed on the left-hand side followed by four recommended movies. Let's try query "Heat".

image_heat

Heat is a 1995 American crime film starring Robert De Niro, Al Pacino. The results look fine. Leaving Las Vegas might not be a good recommendation though. I guess the reason is because Nicolas Cage is in the movie, The ROCK, and it's a good recommendation to an audience who loves Heat. So, it may be one of the disadvantages of using similarity matrix with collaborative filtering. Let's try more examples.

image_toy_story

It looks OK. Toy Story 2 definitely should be recommended to an audience who loves Toy Story. But Forrest Gump doesn't make too much sense to me. Apparently, Tom Hanks' voice is in the Toy Story movies so Forrest Gump was recommended. Note that by just looking at the posters, one can tell the differences such as movie type, mood, etc., between Toy Story and Forrest Gump, right? A child may ignore Forrest Gump when he sees its posters assuming every child likes Toy Story.

Alternating and Stochastic Gradient Descent

In the previous discussion, we simply calculate the cosine similarity of users and items and use this similarity measure to predict user-to-item ratings and also make an item-to-item recommendation. We now formulate our problem as a regression problem. We introduce latent features y for all movies and weight vectors x for all users. The objective is simply to minimize the MSE (with 2-norm regularization terms) of the rating prediction.

eq4

eq5

Note that now both weight vector and feature vector are decision variables. Apparently, this is not a convex problem. Just for now, don't worry too much about convergence property for this non-convex problem. There are many ways to solve this non-convex optimization problem. One approach is by solving weight vectors (for users) and feature vectors (for movies) in an alternating way. When we solve weight vectors, we assume feature vectors are constant vectors. On the other hand, when we solve feature vectors, we assume weight vectors are constant vectors. Another way to solve this regression problem is to combine the updates of the weight vectors and feature vectors, updating them within the same iteration. Also, one can implement stochastic gradient descent to speed up the computation. Here, I use stochastic gradient descent approach to solve this regression problem. The MSE of my prediction is shown below.

learning_curveThe MSE is much smaller than the one obtained by using similarity matrix. Of course, We can also use grid search and cross-validation to tune the parameters of our model and algorithm.

So again, let's see our recommendation by querying movies of interest.

image_heat_cf

It doesn't look good. I don't know these four movies that were recommended to me by querying Heat. They look totally irreverent to Heat. They look like romantic/drama movies. What on earth do I want to watch a drama if I am finding a movie that is similar to American crime film with big movie stars? I find it's very intriguing that a good MSE result may give us a very bad recommendation.

So let's discuss the weaknesses of collaborative filtering based recommendation systems.

-- Collaborative filtering approach finds similar users and movies by usage data, which leads to popular items that will be easier to be recommended than unpopular items.

-- It is difficult for collaborative filtering to recommend any new movies to users since there are no many usage data associated with these movies.

In the next discussion, we will consider a different approach to address the issues of collaborative filtering. We use deep learning to recommend movies to users.

Deep Learning

We will use VGG16 in Keras to train our neural networks. There is no target in our data set and we only consider the fourth-to-last layer as a feature vector. We use this feature vector to characterize each movie in our data set. There are some preprocessing steps before training our neural networks. The training process is summarized below.

In the codes, we first get the movie posters from TMDB website using its API with IMDB id, then we feed posters to VGG16 and train our neural networks, finally, we calculate the cosine similarity using the features learned by VGG16. After we get the movie similarity, then we can recommend similar movies to uses with the highest similarity. Note that there are total 25088 features learned by VGG16 and we use these features to characterize each movie in our data set.

Let's see the recommendation using deep learning.

image_heat_deep

There is no love drama along with Heat! these posters definitely share some common characteristics. They are dark blue, have people in the posters, etc. Again, let's try Toy Story.

image_toy_story_deep

Forest Gump was not recommended! The results look fine! I am very enjoying doing this, so let's try a few more examples.

image_interstellar_deep

Note that these posters have one to two people in them and have a very cold theme or style.

image_avenger_deep

These posters want to let the audience know that the corresponding movies are fun, loud, intensive, and have a lot of actions in them, so the colors and images of the posters are very strong.

image_007_deep

On the other hand, these posters want to show the audience that the corresponding movies are all about a single man.

image_panda_deep

We found some things that are similar to kung fu panda.

image_animal_deep

This is a very interesting one. We indeed found similar monsters and also found Tom Cruse!

image_dress_deep

All these posters have a woman with the similar pose. Wait! is that Shaq!?

image_spider_deep

We successfully found the spider man!

image_deep

This one found the posters with similar typography.

Conclusions

There are several ways to use deep learning in recommendation systems:

-- Unsupervised learning approach.

-- Predict the latent features derived from collaborative filtering.

-- Use the features generated from deep learning as side information.

Movie posters have elements which create the hype and interest in the viewers. In this project, we use deep learning as a unsupervised learning approach and learn the similarity of movies by processing movie posters. Apparently, this is just the first step of using deep learning in recommendation systems. There are so many things we can try. For example, we can use deep learning to predict latent features derived from collaborative filtering. Similar approach has been studied by Spotify for music recommendation. Instead of image processing, they consider using deep learning to predict latent features derived from collaborative filtering by processing sound of a song. Another possible direction is to use the features learned by deep learning as side information to improve prediction accuracy.

Inspired by student projects? Now it's your turn.
Get information about our data science programs and see how we can help you launch your data science career.



 

References:

-- http://blog.ethanrosenthal.com/2015/11/02/intro-to-collaborative-filtering/

-- http://blog.ethanrosenthal.com/2016/01/09/explicit-matrix-factorization-sgd-als/

-- http://blog.ethanrosenthal.com/2016/10/19/implicit-mf-part-1/

-- http://blog.ethanrosenthal.com/2016/11/07/implicit-mf-part-2/

-- http://blog.ethanrosenthal.com/2016/12/05/recasketch-keras/

-- https://www.designmantic.com/blog/2016-movie-poster-design-trends/

-- https://www.designmantic.com/blog/movie-moods-in-typography/

-- http://www.datasciencecentral.com/profiles/blogs/understanding-and-selecting-recommenders-1

-- http://www.datasciencecentral.com/profiles/blogs/5-types-of-recommenders

-- http://benanne.github.io/2014/08/05/spotify-cnns.html

-- Andrew Ng, "Machine Learning," Recommender Systems, 2016

-- Aaron van den Oord, et al., "Deep content-based music recommendation," NIPS, 2013

-- Yifan Hu, et al., "Collaborative Filtering for Implicit Feedback Datasets,"

-- Ste en Rendle, "BPR: Bayesian Personalized Ranking from Implicit Feedback,"

About Author

Wann-Jiun Ma

Wann-Jiun Ma (PhD Electrical Engineering) is a Postdoctoral Associate at Duke University. His research is focused on mathematical modeling, algorithm design, and software/experiment implementation for large-scale systems such as wireless sensor networks and energy analytics. After having exposed...
View all posts by Wann-Jiun Ma >

Related Articles

Capstone
The Convenience Factor: How Grocery Stores Impact Property Values
Machine Learning
Pandemic Effects on the Ames Housing Market and Lifestyle
APIs
Female Artists: MoMA Analysis for Art Collectors
APIs
Music and Audio Quantifying Recommendation Data
APIs
Data Analysis on Local Used Items with Python and Tableau

Leave a Comment

Cancel reply

You must be logged in to post a comment.

Lorene January 14, 2019
You are able to join these tournaments for-free nevertheless you can win hundreds of bucks in real money.
ๅฆ‚ไฝ•็”จๆทฑๅบฆๅญฆไน ๆŽจ่็”ตๅฝฑ๏ผŸๆ•™ไฝ ๅš่‡ชๅทฑ็š„ๆŽจ่็ณป็ปŸ๏ผ | Nokia 108 May 12, 2017
[โ€ฆ] via nycdatascience๏ผŒ้›ท้”‹็ฝ‘็ผ–่ฏ‘ [โ€ฆ]
ๅฆ‚ไฝ•็”จๆทฑๅบฆๅญฆไน ๆŽจ่็”ตๅฝฑ๏ผŸๆ•™ไฝ ๅš่‡ชๅทฑ็š„ๆŽจ่็ณป็ปŸ๏ผ - ่Žน่Žนไน‹่‰ฒ May 12, 2017
[โ€ฆ] nycdatascience [โ€ฆ]

View Posts by Categories

All Posts 2399 posts
AI 7 posts
AI Agent 2 posts
AI-based hotel recommendation 1 posts
AIForGood 1 posts
Alumni 60 posts
Animated Maps 1 posts
APIs 41 posts
Artificial Intelligence 2 posts
Artificial Intelligence 2 posts
AWS 13 posts
Banking 1 posts
Big Data 50 posts
Branch Analysis 1 posts
Capstone 206 posts
Career Education 7 posts
CLIP 1 posts
Community 72 posts
Congestion Zone 1 posts
Content Recommendation 1 posts
Cosine SImilarity 1 posts
Data Analysis 5 posts
Data Engineering 1 posts
Data Engineering 3 posts
Data Science 7 posts
Data Science News and Sharing 73 posts
Data Visualization 324 posts
Events 5 posts
Featured 37 posts
Function calling 1 posts
FutureTech 1 posts
Generative AI 5 posts
Hadoop 13 posts
Image Classification 1 posts
Innovation 2 posts
Kmeans Cluster 1 posts
LLM 6 posts
Machine Learning 364 posts
Marketing 1 posts
Meetup 144 posts
MLOPs 1 posts
Model Deployment 1 posts
Nagamas69 1 posts
NLP 1 posts
OpenAI 5 posts
OpenNYC Data 1 posts
pySpark 1 posts
Python 16 posts
Python 458 posts
Python data analysis 4 posts
Python Shiny 2 posts
R 404 posts
R Data Analysis 1 posts
R Shiny 560 posts
R Visualization 445 posts
RAG 1 posts
RoBERTa 1 posts
semantic rearch 2 posts
Spark 17 posts
SQL 1 posts
Streamlit 2 posts
Student Works 1687 posts
Tableau 12 posts
TensorFlow 3 posts
Traffic 1 posts
User Preference Modeling 1 posts
Vector database 2 posts
Web Scraping 483 posts
wukong138 1 posts

Our Recent Popular Posts

AI 4 AI: ChatGPT Unifies My Blog Posts
by Vinod Chugani
Dec 18, 2022
Meet Your Machine Learning Mentors: Kyle Gallatin
by Vivian Zhang
Nov 4, 2020
NICU Admissions and CCHD: Predicting Based on Data Analysis
by Paul Lee, Aron Berke, Bee Kim, Bettina Meier and Ira Villar
Jan 7, 2020

View Posts by Tags

#python #trainwithnycdsa 2019 2020 Revenue 3-points agriculture air quality airbnb airline alcohol Alex Baransky algorithm alumni Alumni Interview Alumni Reviews Alumni Spotlight alumni story Alumnus ames dataset ames housing dataset apartment rent API Application artist aws bank loans beautiful soup Best Bootcamp Best Data Science 2019 Best Data Science Bootcamp Best Data Science Bootcamp 2020 Best Ranked Big Data Book Launch Book-Signing bootcamp Bootcamp Alumni Bootcamp Prep boston safety Bundles cake recipe California Cancer Research capstone car price Career Career Day ChatGPT citibike classic cars classpass clustering Coding Course Demo Course Report covid 19 credit credit card crime frequency crops D3.js data data analysis Data Analyst data analytics data for tripadvisor reviews data science Data Science Academy Data Science Bootcamp Data science jobs Data Science Reviews Data Scientist Data Scientist Jobs data visualization database Deep Learning Demo Day Discount disney dplyr drug data e-commerce economy employee employee burnout employer networking environment feature engineering Finance Financial Data Science fitness studio Flask flight delay football gbm Get Hired ggplot2 googleVis H20 Hadoop hallmark holiday movie happiness healthcare frauds higgs boson Hiring hiring partner events Hiring Partners hotels housing housing data housing predictions housing price hy-vee Income industry Industry Experts Injuries Instructor Blog Instructor Interview insurance italki Job Job Placement Jobs Jon Krohn JP Morgan Chase Kaggle Kickstarter las vegas airport lasso regression Lead Data Scienctist Lead Data Scientist leaflet league linear regression Logistic Regression machine learning Maps market matplotlib Medical Research Meet the team meetup methal health miami beach movie music Napoli NBA netflix Networking neural network Neural networks New Courses NHL nlp NYC NYC Data Science nyc data science academy NYC Open Data nyc property NYCDSA NYCDSA Alumni Online Online Bootcamp Online Training Open Data painter pandas Part-time performance phoenix pollutants Portfolio Development precision measurement prediction Prework Programming public safety PwC python Python Data Analysis python machine learning python scrapy python web scraping python webscraping Python Workshop R R Data Analysis R language R Programming R Shiny r studio R Visualization R Workshop R-bloggers random forest Ranking recommendation recommendation system regression Remote remote data science bootcamp Scrapy scrapy visualization seaborn seafood type Selenium sentiment analysis sentiment classification Shiny Shiny Dashboard Spark Special Special Summer Sports statistics streaming Student Interview Student Showcase SVM Switchup Tableau teachers team team performance TensorFlow Testimonial tf-idf Top Data Science Bootcamp Top manufacturing companies Transfers tweets twitter videos visualization wallstreet wallstreetbets web scraping Weekend Course What to expect whiskey whiskeyadvocate wildfire word cloud word2vec XGBoost yelp youtube trending ZORI

NYC Data Science Academy

NYC Data Science Academy teaches data science, trains companies and their employees to better profit from data, excels at big data project consulting, and connects trained Data Scientists to our industry.

NYC Data Science Academy is licensed by New York State Education Department.

Get detailed curriculum information about our
amazing bootcamp!

Please enter a valid email address
Sign up completed. Thank you!

Offerings

  • HOME
  • DATA SCIENCE BOOTCAMP
  • ONLINE DATA SCIENCE BOOTCAMP
  • Professional Development Courses
  • CORPORATE OFFERINGS
  • HIRING PARTNERS
  • About

  • About Us
  • Alumni
  • Blog
  • FAQ
  • Contact Us
  • Refund Policy
  • Join Us
  • SOCIAL MEDIA

    ยฉ 2025 NYC Data Science Academy
    All rights reserved. | Site Map
    Privacy Policy | Terms of Service
    Bootcamp Application