Build a Movie Recommender - Machine Learning for Hackers #4

Siraj Raval · Intermediate ·📐 ML Fundamentals ·10y ago

Key Takeaways

This video demonstrates building a movie recommender system using Amazon's Deep Scalable Sparse Tensor Network Engine (Destiny) library in C++, training a neural network on the MovieLens dataset, and deploying it on AWS for prediction.

Full Transcript

hey Siri any songs you'd recommend the black or the berry by Kendrick Lamar Good pick why that one because the police hello world welcome to sty in this episode we're going to build a movie recommender system recommender systems are all around us almost every single major service on the internet uses them to show you things you like based on your interest sometimes it's so subtle you don't even notice they help personalize content on the web which makes users happy which makes companies money I choose Rich every time the two most ubiquitous types of recommender systems are content based and collaborative content based systems focus on each user individually it looks at the items you've already expressed interest in Via likes and ratings and Records their keywords attributes and tags then your profile is gradually built with these attributes once your profile is built the system will start recommending items you like with similar attributes to the ones you've already expressed interest in so if you're on an e-commerce site and you buy a bunch of Nickelback t-shirts those items will have tags like worst band ever and stupid based on that content the system will suggest similarly tagged items for you like cre t-shirts and Walmart brand guitar then there are collaborative systems these are the most ubiquitous types of recommender systems a collaborative system recommends you items based on what other similar users have expressed interest in if you really like base jumping and constantly buy Bas jumping gear online the system will find users who have similar purchase history it can recommend other items they've bought that you haven't it's likely that you'll be into those products as well so we're going to build an app that can recommend movies you'd like in 10 lines of C++ using Amazon's newly released ml Library called Deep scalable sparse tensor Network engine or destiny we've got to think of a better name our model will be a neural network because depending on how deep we make it and how much data we feed it it's just going to outperform everything else let's be real then we're going to train it in the cloud using AWS because I ain't got time to train this on my MacBook Destiny is what Amazon build for production use specifically to recommend products to customers that they might like it's optimized for sparse data and multi-gpu computation data is sparse if it contains a lot of zeros as not a whole lot of valuable information Rex usually operate on sparse data not everything is connected but you can manage to find some valuable links between people and items most ml libraries Implement data parallel training as in it splits training data across multiple gpus this works but there's definitely a trade-off between speed and accuracy Destiny uses model parallel training so instead of splitting the data across multiple gpus it splits the model across multiple gpus so all the layers are spread out across multiple gpus on the same server automatically for you Amazon had to do this because the weight matrices it had for rex that is all the mappings of users and attributes just didn't fit in the memory of a single GPU when it comes to M libraries Destiny isn't as general purpose as tensorflow but it is twice as fast when it comes to dealing with sparse data so we'll follow our methodology and collect our data set build the model train the model and test the model we'll call the retrieve data set method with a parameter as a URL to our downloadable model in our case we're going to use a sample movie lens data set which contains user ratings for a lot of different movies and their Associated tags once we have we want to convert it to a format our ml Library can read in this case it's the net CDF format net CDF is designed for efficient calization of a large array of numbers and it's what Destiny expects we generate for both the input and output layer of our neural network and we'll use the name of the downloaded data set as our parameter both of these functions generate a net cvf file an index file for neurons and an index file for features once we've generated our model it's time to train our neural network in Destiny you build your model in a Json file instead of programmatically we can see in the config.js the structure of the neural network this is where we set our hyper parameters the most important takeaway here is that we are creating a three-layer feedforward neural network that means data just flows one way with one 128 node hidden layer and our activation function at each node is the classic sigmoid which turns values into probabilities we can go ahead and run our train function with the batch size and number of epoch at the parameters we'll set the batch size or number of examples to 256 and the number of epoch or runs to 10 once we run this it'll create a newly trained model file called g. NC which we can then use to predict recommendations our last step is to predict recommendations so we can just call the predict method and set the number of recommendations parameter to 10 this will place the newly created predictions in the Rex file now that we have our code ready to be compiled and run we want to up load it to AWS to start off we'll click on the ec2 button which will take us to Amazon's cloud computing service then we want to make sure we're in the US East North Virginia region since Amazon created a preconfigured image with dependencies like Cuda and open API already set up for us in that region we'll click on Amis under the images directory of the left sidebar and the search for the instance called Ami D6 F2 E6 BC it should pop up and then we'll click the blue launch button to spin up an instance using that image then it'll show us a list of instance types since we want to speed up training time let's go ahead and choose the GPU option here then we'll click review and launch and see the final page before we can launch our instance everything looks good to go so let's click launch it'll prompt you to create a new key pair go ahead and download it so you have it locally this will have authorize your machine to connect to AWS now that we've successfully launched a GPU inance we need to upload our code to it and train it I'm a fan of using filezilla to upload files so let's use that we'll click the site manager icon then paste in the host name we got to be sure to set the protocol to SFTP then set the login type to normal and the user is called Ubuntu once we've set the fields we can click connect and it'll show us all the current files in our instance let's go ahead and drag and drop our project into the root folder now that our code is in our ec2 instance we can can open up terminal and SSH into it we can find the SSH snippet for terminal under the instances section once we click the connect button perfect let's just paste this baby right into terminal boom we're in let's CD into our directory before we run our code we'll need to do two things add the npic and nvcc compilers to our path and make the library we can export npic and then run make then we'll export nvcc now we can run our script and once that's done we'll have Rex and our Rex folder that's pretty much it you can scale your neural net accordingly depending on the size of your data check out the links down below and please subscribe for more machine learning videos I've got to go fix a runtime error so thanks for watching

Original Description

This video will get you up and running with your first movie recommender system in just 10 lines of C++. We train a neural network on a MovieLens dataset of movie ratings by different users to generate a top 10 recommendation list for the default user ID. The code for this video is here (everything included): https://github.com/llSourcell/Movie_Recommender I created a Slack channel for us, sign up here: https://wizards.herokuapp.com/ The Original Amazon DSSTNE code is here: https://github.com/amznlabs/amazon-dsstne Link to AWS: https://aws.amazon.com/ Link to FileZilla: https://sourceforge.net/projects/filezilla/ Paper I found pretty cool (a deep learning based rec system): https://arxiv.org/pdf/1409.2944.pdf And a correction -- Scott grand recently tested it vs Tensorflow and reported not just a 2x, but a 15x speedup: https://medium.com/@scottlegrand/first-dsstne-benchmarks-tldr-almost-15x-faster-than-tensorflow-393dbeb80c0f#.loze1hltg I love you guys! Thanks for watching my videos, I do it for you. I left my awesome job at Twilio and I'm doing this full time now. I recently created a Patreon page. If you like my videos, feel free to help support my effort here!: https://www.patreon.com/user?ty=h&u=3191693 Much more to come so please subscribe, like, and comment. Follow me: Twitter: https://twitter.com/sirajraval Facebook: https://www.facebook.com/sirajology Instagram: https://www.instagram.com/sirajraval/ Instagram: https://www.instagram.com/sirajraval/ Signup for my newsletter for exciting updates in the field of AI: https://goo.gl/FZzJ5w Hit the Join button above to sign up to become a member of my channel for access to exclusive content! Join my AI community: http://chatgptschool.io/ Sign up for my AI Sports betting Bot, WagerGPT! (500 spots available): https://www.wagergpt.xyz
Watch on YouTube ↗ (saves to browser)
Sign in to unlock AI tutor explanation · ⚡30

Playlist

Uploads from Siraj Raval · Siraj Raval · 18 of 60

1 What is Bitcoin?
What is Bitcoin?
Siraj Raval
2 5 Ways to Use Bitcoin
5 Ways to Use Bitcoin
Siraj Raval
3 BTC Fever - Siraj [Music Video]
BTC Fever - Siraj [Music Video]
Siraj Raval
4 5 Reasons to Build Decentralized Apps
5 Reasons to Build Decentralized Apps
Siraj Raval
5 The Interplanetary File System
The Interplanetary File System
Siraj Raval
6 How to Build a Dapp in 3 min
How to Build a Dapp in 3 min
Siraj Raval
7 Life Before Smartphones
Life Before Smartphones
Siraj Raval
8 4 Ways to Use Smart Contracts
4 Ways to Use Smart Contracts
Siraj Raval
9 3 Dapps You HAVE to See
3 Dapps You HAVE to See
Siraj Raval
10 Char's Life as a BitTorrent Engineer
Char's Life as a BitTorrent Engineer
Siraj Raval
11 4 Reasons AlphaGo is a Huge Deal
4 Reasons AlphaGo is a Huge Deal
Siraj Raval
12 Build a Neural Net in 4 Minutes
Build a Neural Net in 4 Minutes
Siraj Raval
13 Sentiment Analysis in 4 Minutes
Sentiment Analysis in 4 Minutes
Siraj Raval
14 The Hackathon Life
The Hackathon Life
Siraj Raval
15 Your First ML App - Machine Learning for Hackers #1
Your First ML App - Machine Learning for Hackers #1
Siraj Raval
16 Build an AI Composer - Machine Learning for Hackers #2
Build an AI Composer - Machine Learning for Hackers #2
Siraj Raval
17 Build a Game AI - Machine Learning for Hackers #3
Build a Game AI - Machine Learning for Hackers #3
Siraj Raval
Build a Movie Recommender - Machine Learning for Hackers #4
Build a Movie Recommender - Machine Learning for Hackers #4
Siraj Raval
19 Build an AI Artist - Machine Learning for Hackers #5
Build an AI Artist - Machine Learning for Hackers #5
Siraj Raval
20 Build a Chatbot - ML for Hackers #6
Build a Chatbot - ML for Hackers #6
Siraj Raval
21 Build an AI Reader - Machine Learning for Hackers #7
Build an AI Reader - Machine Learning for Hackers #7
Siraj Raval
22 Build an AI Writer - Machine Learning for Hackers #8
Build an AI Writer - Machine Learning for Hackers #8
Siraj Raval
23 Build a Chatbot w/ an API - ML for Hackers #9
Build a Chatbot w/ an API - ML for Hackers #9
Siraj Raval
24 One-Shot Learning - Fresh Machine Learning #1
One-Shot Learning - Fresh Machine Learning #1
Siraj Raval
25 Generative Adversarial Nets - Fresh Machine Learning #2
Generative Adversarial Nets - Fresh Machine Learning #2
Siraj Raval
26 Tone Analysis - Fresh Machine Learning #3
Tone Analysis - Fresh Machine Learning #3
Siraj Raval
27 Generate Rap Lyrics - Fresh Machine Learning #4
Generate Rap Lyrics - Fresh Machine Learning #4
Siraj Raval
28 Build an Autoencoder in 5 Min - Fresh Machine Learning #5
Build an Autoencoder in 5 Min - Fresh Machine Learning #5
Siraj Raval
29 Build a Self Driving Car in 5 Min - Fresh Machine Learning #6
Build a Self Driving Car in 5 Min - Fresh Machine Learning #6
Siraj Raval
30 Build an Antivirus in 5 Min - Fresh Machine Learning #7
Build an Antivirus in 5 Min - Fresh Machine Learning #7
Siraj Raval
31 TensorFlow in 5 Minutes (tutorial)
TensorFlow in 5 Minutes (tutorial)
Siraj Raval
32 Build a Recurrent Neural Net in 5 Min
Build a Recurrent Neural Net in 5 Min
Siraj Raval
33 Build a Simulation in 5 Min
Build a Simulation in 5 Min
Siraj Raval
34 Build a TensorFlow Image Classifier in 5 Min
Build a TensorFlow Image Classifier in 5 Min
Siraj Raval
35 Tensorboard Explained in 5 Min
Tensorboard Explained in 5 Min
Siraj Raval
36 Generate Music in TensorFlow
Generate Music in TensorFlow
Siraj Raval
37 Build a Game Bot (LIVE)
Build a Game Bot (LIVE)
Siraj Raval
38 Deep Learning Frameworks Compared
Deep Learning Frameworks Compared
Siraj Raval
39 Introduction - Learn Python for Data Science #1
Introduction - Learn Python for Data Science #1
Siraj Raval
40 Build a Neural Network (LIVE)
Build a Neural Network (LIVE)
Siraj Raval
41 Twitter Sentiment Analysis - Learn Python for Data Science #2
Twitter Sentiment Analysis - Learn Python for Data Science #2
Siraj Raval
42 Recommendation Systems - Learn Python for Data Science #3
Recommendation Systems - Learn Python for Data Science #3
Siraj Raval
43 Predicting Stock Prices - Learn Python for Data Science #4
Predicting Stock Prices - Learn Python for Data Science #4
Siraj Raval
44 Pong Neural Network (LIVE)
Pong Neural Network (LIVE)
Siraj Raval
45 Deep Dream in TensorFlow - Learn Python for Data Science #5
Deep Dream in TensorFlow - Learn Python for Data Science #5
Siraj Raval
46 Visualizing Data with D3.js (LIVE)
Visualizing Data with D3.js (LIVE)
Siraj Raval
47 Genetic Algorithms - Learn Python for Data Science #6
Genetic Algorithms - Learn Python for Data Science #6
Siraj Raval
48 Enter Siraj [Music Video]
Enter Siraj [Music Video]
Siraj Raval
49 Build a Web Scraper (LIVE)
Build a Web Scraper (LIVE)
Siraj Raval
50 Why is P vs NP Important?
Why is P vs NP Important?
Siraj Raval
51 How to Make a Neural Network (LIVE)
How to Make a Neural Network (LIVE)
Siraj Raval
52 How to Make an Amazing Tensorflow Chatbot Easily
How to Make an Amazing Tensorflow Chatbot Easily
Siraj Raval
53 How to Make an Amazing Video Game Bot Easily
How to Make an Amazing Video Game Bot Easily
Siraj Raval
54 How to Make a Tensorflow Neural Network (LIVE)
How to Make a Tensorflow Neural Network (LIVE)
Siraj Raval
55 How to Make a Simple Tensorflow Speech Recognizer
How to Make a Simple Tensorflow Speech Recognizer
Siraj Raval
56 Joel Shor - Really Quick Questions with an Awesome Google Engineer
Joel Shor - Really Quick Questions with an Awesome Google Engineer
Siraj Raval
57 How to Make a Path Planning Algorithm Easily (LIVE)
How to Make a Path Planning Algorithm Easily (LIVE)
Siraj Raval
58 The Best Way to Prepare a Dataset Easily
The Best Way to Prepare a Dataset Easily
Siraj Raval
59 Catherine Olsson - Really Quick Questions with an OpenAI Engineer
Catherine Olsson - Really Quick Questions with an OpenAI Engineer
Siraj Raval
60 How to Make a Tic Tac Toe Neural Network Easily (LIVE)
How to Make a Tic Tac Toe Neural Network Easily (LIVE)
Siraj Raval

This video teaches you how to build a movie recommender system using Destiny library in C++ and deploy it on AWS. You'll learn about collaborative and content-based filtering, and how to train a neural network on a dataset.

Key Takeaways
  1. Collect and preprocess the MovieLens dataset
  2. Build a neural network using Destiny library
  3. Train the model on the dataset
  4. Deploy the model on AWS
  5. Use the model for prediction
💡 Model parallel training can be more efficient than data parallel training for sparse data and multi-gpu computation.

Related AI Lessons

10 Python Concepts You Must Know Before Calling Yourself Advanced
Learn 10 essential Python concepts to take your skills to the advanced level and stand out as a developer
Medium · AI
10 Python Concepts You Must Know Before Calling Yourself Advanced
Learn 10 crucial Python concepts to elevate your skills from intermediate to advanced and become a proficient developer
Medium · Data Science
10 Python Concepts You Must Know Before Calling Yourself Advanced
Learn 10 essential Python concepts to take your skills to the advanced level and stand out as a developer
Medium · Programming
10 Python Concepts You Must Know Before Calling Yourself Advanced
Learn 10 essential Python concepts to take your skills to the advanced level and separate yourself from beginner developers
Medium · Python
Up next
Is Python Dead in 2026?| Truth About Python in AI Era | 90 Days Roadmap @FameWorldEducationalHub
FAME WORLD EDUCATIONAL HUB
Watch →