Hands-On Guide To RecBole Recommendation Algorithms
Have you ever noticed that many of the product selling, service providing, and content providing companies like amazon, Oyo, youtube, Netflix, and Flipkart provide suggestions or recommendations about their products, services, and content us? Many of the recommendations we use because we know the quality of those products and many of the products we use because the platform where we are surfing for products or services knows about the product that hopefully we may like or require to use in future. How do those recommendations come out in front of us while using the platforms? The companies we are talking about are some leading companies in the market in today’s scenario. One of the factors that adds to their current stature is their recommendation system. Recommendation systems are designed to give recommendations about the user’s services, products, or items based on different factors. These systems predict probabilities about the products which are used by users most likely.  Using those recommendation systems, a user can figure out their requirements. These systems deal with the information provided by the user about the user or about the product they want to use. It finds out the match between users information and product requirements and imputes the similarity between users and items for recommendation. Recommendation systems are beneficial for both sides, for the user side as well as the provider. It benefits the user to make it easy and save time for searching the things he is interested in and for the provider to place his services in the right place and improve the user experience.  Many things can be recommended like movies, books, news articles, videos, etc., and many platforms are using it to grow their business. There are many types of recommendation systems. Some of them are- Popularity-based recommendation system – This system recommends the products in trend like a youtube trending page where the page recommends the videos viewed by the users in high frequency.Content-based recommendation system – This type of recommendation system provides the recommendation based on the similarity of the content; for example, in Netflix, the platform will recommend similar movies to the viewer after watching the movie.User-based recommendation system – In this type of recommendation system, the system calculates the similarity between the users based on users information like gender, age, like, dislike etc. and then gives the recommendation based on the similar user’s service consumption data. For example, Amazon gives recommendations about the kids’ accessories based on the age of the kids. These all systems are somewhere having different algorithms for implementation in a platform. And to assign recommendation systems to a platform we all need to imply all recommendation systems differently. Because, commonly, every business needs higher user engagement in their platform to grow more. If a user finds the platform useful for him, he uses the platform frequently, and a recommendation system helps provide a better user experience to platform users. Choosing recommendation systems to embed with a platform requires a lot of knowledge. Also, it is the subject of research because a single failure can cause the loss of several customers. And that can also harm the business too. And this subject is too deep; what we have discussed earlier is just the basic things about the recommendation system. Implementation of the recommendation system is needed to be very accurate, and also, by the time of implementation, it should give a high level of accuracy and proper recommendations. Here RecBole takes part in, which can make these all tasks very easy to perform. Next, in the article, we will discuss the RecBole framework designed for research purposes in recommendation systems. What is RecBole? RecBole,’s library consists of 72 Algorithms of recommendation systems. It is developed in Python on PyTorch framework. It produces recommendation algorithms in a unified and comprehensive way by covering four major categories of recommendation algorithms. General recommendationSequential recommendation.Context-aware recommendation.Knowledge-based recommendation. Also, with all these algorithms in its library, we have 28 recommendation data sets available, which are designed to be flexible with the algorithms. There are some scripts also available to preprocess the datasets to fit in those algorithms. The following image can show the overall architecture of the RecBole. Image source Implementation Of RecBole in Python Let’s see how we can work with RecBole. Requirements – python 3.6 or above version,  torch version 1.6.0 or above , CUDA version 9.2 or above, NVIDIA driver version >= 396.26 (for Linux) or >= 397.44 (for Windows10). Here in this article, we are using google colab, so we need to start with mounting the drive in our colaboratory; we can use the following codes for mounting the drive. from google.colab import drive drive.mount('/content/drive') Output: We can access the authorization code from the provided link after copying the code, paste it in the widget, and press enter. Our google drive will get mounted in the drive. We can install the Recbole using the following command. !pip install recbole Output: Or we can directly clone the package from GitHub using the following command. !git clone https://github.com/RUCAIBox/RecBole.git Output: After cloning the package, we just need to direct the colaboratory to the package folder. cd RecBole Output: After directing the colaboratory, we can install the Recbole framework using the following command. !pip install -e . --verbose Output: After installation, we can run the provided script by the package for initial usage of the library. This script will run the BPR model in ml- 100k dataset. The data sets consist of movie title   release year and their class like a thriller, action, adventure etc., with their unique id. !python run_recbole.py That will provide different outputs, which will consist of details of the system, model, data set, and final result. Output: In the above output, we can see the system configuration of the whole process. In the above output, we can see the details of the model in training. In the above output, we can see the evaluation metrics of the script. In the above output, we can see the details of the data. And at the end, we can see the best result of the algorithm. We can also set the different parameters using the following command. python run_hyper.py --model=[model_name] --dataset=[data_name] --config_files=xxxx.yaml --params_file=hyper.test In this command, the hyper.test file consists of those parameters. learning_rate loguniform -8, 0embedding_size choice [64, 96 , 128] train_batch_size choice [512, 1024, 2048] mlp_hidden_size choice ['[64, 64, 64]','[128, 128]'] Where loguniform indicates, the parameter will follow the randomly taken values between  e^{-8}- e^{0} in a uniform distribution. And choice allows you to take discrete values from the setting list. Basically, this file is providing the hyperparameter tuning of the model. We can use different numbers in the hyper.test file available in RecBole/hyper.test location. For example, I am setting the parameters in the following codes. !python run_hyper.py --model=BPR --dataset=ml-100k --params_file=hyper.test Output: The output will start like this, and it will take some time to get completed. Here is the final result of the model after hyperparameter tuning. Validation result. Test result: Here we can see the results are quite satisfying, and also, we can just make a recommendation system in only a few steps. The library is tested on different datasets like Ml-1m, Netflix, yelp data. We can check the whole details of the models and performance in this link. Here in the article, we have seen how to generate a recommendation model. We could also iterate between different models by just putting a single line of command, and the RecBolde made the whole recommendation system easy and fast. The code used in the start took just 1 minute to complete, and the hyperparameter tuning took around 3-4 minutes to run successfully. Using RecBole we don’t need to worry about the algorithms. We also have got comprehensive details about the whole process running in the background. I encourage you to go to the link and learn more about the library because it can generate models with high precision levels. References: RecBole github.RecBole homepage.Google colab for implemented codes in this article.
RecBole is a python package for various recommendation system algorithms. which covers four major categories of recommendation system with 72 algorithms
RecBole produces recommendation algorithms in a unified and comprehensive way by covering four major categories of recommendation algorithms.
["AI (Artificial Intelligence)", "Data Science", "Data Scientist", "Deep Learning", "Guide", "Machine Learning", "Python", "recommendation", "recommendation engine", "recommender systems"]
["TPU", "R", "CUDA", "PyTorch", "RAG", "Data Science", "Guide", "AI", "ML", "Machine Learning", "recommendation systems", "recommender systems", "Python", "recommendation engine", "Colab", "recommendation", "Deep Learning", "Data Scientist", "AI (Artificial Intelligence)"]
["AI", "ML", "PyTorch", "Colab", "RAG", "recommendation systems", "TPU", "CUDA", "Python", "R"]
Yugesh is a graduate in automobile engineering and worked as a data analyst intern. He completed several Data Science projects. He has a strong interest in Deep Learning and writing blogs on data science and machine learning.