Creating a recommendation engine using ML.NET Model Builder

Creating a recommendation engine using ML.NET Model Builder

More and more has been saying recently about the concept of no code. It is a platform for building applications without coding. You can create software and configure everything using just the mouse, a perfect way for non-technical people. ML.NET Model Builder can be described as a small seed of this solution. In this article, I want to show you how easily can you create a prediction model for your recommendation application with a few clicks.

ML.NET Model Builder

Model Builder is a tool available in Visual Studio that uses AutoML and specific algorithms available in the ML.NET library. This allows you to create machine learning models without any experience in this area or programming skills. Sounds perfect, right?
At the beginning of its existence, this tool had to be installed separately. Now it is available right away in the IDE. To start working with it, you need to check the following checkbox in the settings:

Dataset and the problem studied

I used the Recommendation System Movie dataset from Kaggle for the experiment. The analyzed data set has 4 features and 100004 instances.

The problem we want to solve is creating a model that will be able to predict how a given movie (item_id) would be rated by a given user (user_id). Thanks to algorithms of this type on the website with movies, it is possible to propose certain titles for the user according to his preference.

Building model using ML.NET Model Builder

After creating a console application project and doing the step that I mentioned earlier, you can proceed to build a machine learning algorithm. In the first step, open the context menu of your project and select the ‘Add’ tab there and then ‘Machine Learning’. You should now see something like this:

So click on the ‘Recommendation’ field and then load the previously downloaded dataset. Then, set the appropriate columns as shown in the screenshot below:

You can now move on to training the model. Maybe you are wondering now for what time to set this process? Microsoft has created a table where it suggests to set the training time depending on the size of the data file:

Due to the fact that our dataset weighs less than 2MB, we should set it to 10 seconds but we should also consider the complexity of the problem. For this reason, let’s set it to 1000 seconds and the learning process can begin:

In the graphic above, we can see the result of R-squared. It represents the predictive power of the model. 1.00 means there is a perfect fit and 0.00 means the model is guessing the expected value for the label. It can be concluded that our result is not very good, but we should also take into account the complexity of the problem as I mentioned earlier. However, it would require more analysis and use of other metrics, and this is material for another blog post.
Let’s check how the learned model is doing and what it returns to us. The app returns us the estimated user rating for the movie and the top 5 recommendations for the user.

You can also generate the code of the created model. This will allow you to edit the algorithm or adapt it to your needs. I think it is a useful option as well.


For the more inquisitive, it is worth mentioning that the Matrix Factorization is used here. It is a frequently used model in recommendation systems. As for the theory of the algorithm, I encourage you to read this article. In this blog post, I wanted to show you ML.NET Model Builder and its capabilities. This is still being developed by Microsoft developers, so I think this is just the beginning.

Leave a Reply

Your email address will not be published.

Scroll to top