>> In this video,
we will take a look at how to build a custom machine
learning model for movie recommendations.
Let's go and understand how does movie recommendation
works and what are the different ways of recommending movies.
The most common way of recommending movies is by rating.
So let's assume, you have a website
where people can browse and
see movies and they can rate all the movies.
So the simplest recommendation system is recommend
me movies if the rating is higher than 8,
and so that's one way of recommending movies.
The second way of recommending
movies is by content based filtering.
So this is around movies of certain genre are very popular.
So for example, recommend me
action movies based on my browsing history if I
like a lot of action movies or recommend me
superhero movies if I like a lot of superhero movies.
The third approach is around collaborative filtering,
which combines the first two approaches.
What this approach comes down to is,
let's say there are different users who have
different browsing or viewing habits.
In this case, what's happening
here is we have three users, Ankit, Gal,
and Cesar, and there are three different patterns for Heat,
Mission Impossible, and Home Alone.
The question over here is,
what's the probability of Gal liking Home Alone?
Collaborative filtering is observing the behaviors
of users who have common likes and common dislikes.
So for example, in this case,
we know that Cesar likes Heat and mission Impossible,
and Gal also likes Heat and Mission Impossible.
So if Cesar and Gal have similar viewing habits,
and Cesar doesn't like Home Alone,
then it's more likely that Gal also doesn't like Home Alone.
So this is collaborative filtering and this is what we
can use in our movie recommendation example.
Let's understand what the data looks like
for a typical scenario for recommending movies.
This is a typical dataset,
which also becomes your features or your input
to your model in terms of how do you want to recommend movies.
We have user IDs,
we have movie IDs,
and movie names, or movie genres, and ratings,
and timestamp, and this dataset is directly capturing what
were the viewing habits of these set of users.
Then, what did they actually like in terms of ratings,
and what did they actually see in terms of movies which
has information around what was the genre of the movie,
and other characteristics as well.
The output or the column that you want to predict,
or the output of your machine learning model becomes the rating,
which means, what's the likelihood of
this user liking the movie or not?
So you're going to recommend a set of movies to a user based on
their browsing history or their likes and dislikes using
the collaborative filtering approach that we just saw.
Now that we've understood the basics of movie recommendation,
let's see how movie recommendation model
can be built and used in your application.
So I have two projects in my solution,
one is on how the model was trained,
and the other is a web application
where I'm going to use the model.
So let's look at the how the model was trained as well.
We know that in a typical machine learning workflow,
the first steps are around loading your data.
So in this case, I have loaded data from my ratings dataset,
which has the ratings for
all the users along
with the movie that they saw and the rating that they gave.
I'm going to "featurise" all the values of the movies,
and I'm going to use this as input features.
So my user ID and movie ID are going to become my input features.
For my training algorithm,
I'm going to use field aware factorization machine,
where I'm going to input all the features,
and I'm going to train the model.
Then I'm going to evaluate the model by trying out that model on
a specific user and then seeing what
the top five movies that I can recommend to the user as well.
So let's go ahead and run this application first,
and so let's launch it.
What this will do is it'll load the dataset,
it will extract all the features,
it will train the model,
evaluate the model, and then try the model as well.
So in this case, it evaluated the model
with around 60 percent accuracy,
and for a user ID six with movie ID 10,
the probability of me liking movie ID is about 45 percent.
So that's an example of building a recommendation model.
Let's switch over to
our web application and see this model in practice.
So this is ASP.net web application.
You can imagine that this is your movie site,
where I have three users Ankit, Amy, and Cesar.
If I click Ankit,
you can see that this is
the browsing history for Ankit where he's watched Heat,
Terminator 2, Independence Day,
and these are the all time Box-Office movies
that are popular all up.
So when I click "Recommend",
what I want to find out is,
of all the top Box-Office movies,
which are the ones that Ankit is most likely to see?
So if I click "Recommend",
you would see that there is
a 56 percent chance that Ankit like Face/Off,
88 percent chance that Ankit like Casino Royale,
and 85 percent chance that Ankit might like Gladiator.
If I go back to my site and switch to
Cesar and recommend movies for Cesar as well,
you will see that Cesar has
about 70 percent likelihood of flaking Gladiator.
If you look at how this was built,
I can go over to my movies controller,
and I can go to the recommend action,
where what we're doing over here is we are
loading the machine learning model that we just built,
and we're calling the prediction engine for that particular user,
and getting the list of movies that the user is going to like,
and we're going to update the view with
that particular information as well.
So this is how you can start
incorporating recommendation into your application.
So what we saw over here was how to build
a custom machine learning model for movie recommendation.
In the next video,
we will take a look at how to build
a machine learning model for classifying images.