Create a Recommendation Model in ML.NET

Video Statistics and Information

Video
Captions Word Cloud
Reddit Comments
Captions
hey everyone and welcome in this video I look at a book rating data set from Goodreads and will create a recommendation model using MLM net note that this will be using version 0.7 of mo net for some reason I've been getting some errors when using 0.8 with this project but as soon as they resolved I will mention how to update this example to 0.8 now let's take a quick look at the data set itself it's from kegels so the data is mainly a pre-processed already there are two CSVs that i'll be using their ratings file which has each user ID book ID and the user's rating for the book there's also the book features CSV which has all the details for each book and this is mainly for getting the book details for the IB so I'm in visual studio and a dinette core console project I already have the project set up to get started for instance already have them emailed a net zero point seven package downloaded and have put in the datasets into the project no debt for this recommendation model I also need them Microsoft email that matrix factorization package since we will be using the matrix factorization trainer for a good explanation about matrix factorization there's a link to a good video for it in the description alright so the first thing to do here is to set up where to get the data from so I'll get the data path set up and then get a variable to hold where the data is and then I need to read in the data first though I need to create the ml context now I can create the text reader from it and this takes in an instance of the text loader arguments as a parameter so I can use this to tell how the data looks for instance I can see what separator it has and if it has a header I can also specify the columns there's only three columns here the rating which are called label the user in the book ID now said that data counter or for which I believe is a float and then I'll tell at which location they're on the file what does it up we can call the read on the reader and pad in the path of the data now I like to split my data so I can use some of it to test my model with to do this I'll call a train test split method that's located on the context and the binary classification property give it the data from the reader above and then I'll put in a test fraction as zero point to note that I have the parentheses in the variable and this is because the Train test split method returns a tuple the first item is the training data and the second item is the test data now that we have our data prepared this build our pipeline the first thing to do is to encode or user and book IDs so we'll use the map value two key method that's on the context that transforms the categorical property and this method takes in the original column name we use when reading the data at first I'll do the user they're not do not encode the book ID for each one of these items you can use the a pin method to attach them to the Python and the last item in the pop-on will be to use the algorithm and as mentioned above are used to matrix factorization trainer now pass in the context as well as the string with the label name which I named label from the reader and then I'll use the encoded user ID and book ID names I can add some advanced settings such as the number of iterations that it goes through which I'll said to 20 and the number of K to 100 which you can think of it as using k-means clustering within this trainer with the pop-up setup I can now train the model by calling a fit method and passing in the training data all right so now that I had the model is evaluated with the test set and in order to do that I need to transform it the same way I did a training set and all I need to do is to call the transform method of the model and given the training data set so now that we have the same kind of data and attest that as in the training set I can just call it a context that regression that evaluate method and give it a transform test set and that would give us regression metrics such as root mean squared and R squared that we can use to evaluate how good the model is and last I want to be able to make a recommendation from the model and before I can do that I do need to make some classes specifically the classes that hold a schema of the input data and another to hold the prediction output I'll create a new class and name a book writing and in here I just add a few fields fields label user and book ID I'll create another new class and call the book rating prediction and then we just have label and score fields on it now with those created I can now make the prediction function by calling to make prediction function off of the model and since its generic at the book rating and book rating prediction for the input and output classes and they pass in the context as a parameter and now that prediction function is created I can now make a prediction on it so I'll take a random user and book IDs and then pass those in and then I look at the output score to see what the predictive rating is now I run this and see what we get you'll see when it's training it goes through some root mean squared error information for each iteration and then there is also the model evaluation metrics then there's the prediction so if the user that we chose or model predicts that they will read the book that we chose is around two and there we have it we have a recommender for book ratings use an ml net I hope you learned something from this video and if you like more videos like this please subscribe thanks for watching and I'll see you next time
Info
Channel: Jon Wood
Views: 11,532
Rating: undefined out of 5
Keywords: c#, recommendation model, machine learning
Id: 4AY4IYYf7F4
Channel Id: undefined
Length: 6min 28sec (388 seconds)
Published: Sat Jan 05 2019
Related Videos
Note
Please note that this website is currently a work in progress! Lots of interesting data and statistics to come.