September 6th, 2019

Driverless AI can help you choose what you consume next

RSS icon RSS Category: H2O Driverless AI, Machine Learning, Recipes, Recommendations, Technical, Tutorials

Last updated: 09/06/19

Steve Jobs once said, “A lot of times, people don’t know what they want until you show it to them’. This makes sense, especially in this era of constant choice overload. Consumers today have access to a plethora of products just at the click of their mouse. These innumerable choices can sometimes turn out to be confusing and hampering and do more harm than good. For instance, a company may offer millions of products on its website, but how does a consumer find a new and appealing product from amongst those? Also, wouldn’t it be great if the company could provide choices to every consumer based on their past shopping history? This would not only save a lot of time but also provide them with highly personalized experiences. Such a customized filter relying on modern machine learning techniques constitutes a Recommendation System, and we shall see how Driverless AI can be used to create one.

Recommender Systems

Please note that in this article, the terms recommendation engine, recommender system and recommendation system will be used interchangeably and signify the same underlying idea.

Benefits of using Recommendation systems

Some of the businesses that stand to gain from Recommendation Systems:

Types of Recommender Systems

  • What we want to identify and,
  • What kind of relationship is specified in our data?

Some of the common approaches used for recommendations include:

Approaches used for Recommendation systems

Let’s have a brief overview of each one of them:

1. Content-Based Filtering

The diagram above(source) shows that if a user likes a book in the ‘Literature’ category, it makes sense to recommend books in the same category to the user. Also, recommending books released in the same year and by the same Author would also be a great idea.

2. Collaborative Filtering

3. Hybrid Filtering

Both Content-based and Collaborative approaches have their strengths and weaknesses, and one can end up with a better system by combining many algorithms in what we call a hybrid approach. Hybrid systems leverage both item data and transaction data to give recommendations.

For instance, in the figure below, recommendations are not only based on what people’s reading and searching habits(collaborative systems)but books sharing similar characteristics(content-based) are also recommended.

Creating a Recommender system using Driverless AI

Driverless AI(1.7.0 and above) implements a key feature called BYOR, which stands for Bring Your Own Recipes. Recipes are customizations and extensions to the Driverless AI platform. One can create their own recipes, or select from several recipes available in the repository. We shall use one of the available recipes to develop a Recommender system with Driverless AI.


It is important to note here that this is a regression problem. However, where we would want to predict if the user will buy a particular item or not, it will be a classification problem.


The original data contains over 20 million ratings from 138,000 thousand randomly-chosen, anonymous users. However, for this article, we shall only be using a portion of the original data so that others can quickly reproduce the experiment. The sampled dataset data can be accessed from here. Here are the first few rows of the training data:

First few rows of the training data
  • userId: Customer IDs
  • movieId: Unique ID for every movie
  • rating: On a scale from 1 to 5. This is also the Target variable.
  • timestamp: Date and time on which the ratings were given.
  • releaseYear: The year in which the movie was released.

Driverless AI Recommender System recipes can be used to create Collaborative, Content-based as well as Hybrid Recommender systems.

Collaborative Filtering Methodology

1. Uploading data into Driverless AI

Columns selected for Collaborative Filtering

2. Uploading Custom recipes

Recommender recipe

Edit these values in the code file, save it and then upload the recipe to the Driverless AI experiment as follows:

Uploading Custom recipe

Next, select only the RecH2OMFTransformer and deselect all the other transformers by navigating to Expert Settings>Recipes>include specific Transformers.

Selecting RecH2OMF Transformer

Select Regression as experiment type and RMSE as the scorer and launch the experiment.

Collaborative Filtering Experiment in Driverless AI

Let’s try and understand very briefly, what the Matrix Factorization transformer does under the hood.

  • It first converts the movie rating dataframe into an user-item matrix, also called a utility matrix as follows:

Every cell of the matrix is populated by the ratings that the user has given for the movie. It factors a sparse rating matrix X (m by n, with N_z non-zero elements) into an m-by-kand a k-by-f matrix, where Latent factors are represented by K. This reconstructed matrix populates the empty cells in the original user-item matrix, and so the unknown ratings in the sparse matrix are now known.

  • Implementing the MF technique through H2O4GPU

Matrix Factorization is a commonly used technique in collaborative filtering for decomposing the user-item interaction matrix into the product of two lower dimensionality rectangular matrices. The idea behind matrix factorization is to represent users and items in a lower-dimensional latent space.

In Driverless AI, the Matrix Factorization technique is implemented through h2o4gpu.solvers.factorization module. H2O4GPU is an open-source project consisting of a collection of GPU solvers by H2Oai with APIs in Python and R. The Python API builds upon the easy-to-use scikit-learn API and its well-tested CPU-based algorithms.h2o4gpu.solvers.FactorizationH2O implements Matrix Factorization on GPU with Alternating Least Square (ALS) algorithm.

Content-Based Filtering Methodology

Next, we shall deselect the RecH2OMFTransformer while keeping all the default ones intact. Keeping all the other parameters, the same as the previous experiment hit the launch button.

Hybrid Filtering Methodology

Make sure the RecH2OMFTransformer is reflected along with other selected transformers on the experiment page. Go ahead and launch the experiment. Driverless AI will build multiple features using the various transformers and try multiple models to optimize the weights between the content-features and collaborative-features.

Experiment Results Summary

The pure collaborative approach has an RMSE of 0.96 while the content-based approach has an RMSE of 0.94. The hybrid approach combines both and clearly outperforms each with an RMSE of 0.92.

It is also interesting to note that XGBoost scores 0.98 on the raw features while LightGBM scores 0.99 on the same MovieLens dataset. Therefore, it is safe to conclude that Driverless AI’s recommendation recipes combined with its feature engineering and model-optimization perform better as compared to using plain open-sourced algorithms.

Top N recommendations

Once the experiment is done, users can download the predictions, just like any other Driverless AI experiment.

We can then sort all of the predicted ratings and get the top N recommendations for the user. We would also want to exclude or filter out items that a user has already interacted with before. In the case of movies, there is no point in recommending a movie that a user has previously watched.



About the Author

Parul Pandey

Parul focuses on the intersection of, data science and community. She works as a Principal Data Scientist and is also a Kaggle Grandmaster in the Notebooks category.

Leave a Reply

H2O LLM DataStudio Part II: Convert Documents to QA Pairs for fine tuning of LLMs

Convert unstructured datasets to Question-answer pairs required for LLM fine-tuning and other downstream tasks with

September 22, 2023 - by Genevieve Richards, Tarique Hussain and Shivam Bansal
Building a Fraud Detection Model with H2O AI Cloud

In a previous article[1], we discussed how machine learning could be harnessed to mitigate fraud.

July 28, 2023 - by Asghar Ghorbani
A Look at the UniformRobust Method for Histogram Type

Tree-based algorithms, especially Gradient Boosting Machines (GBM's), are one of the most popular algorithms used.

July 25, 2023 - by Hannah Tillman and Megan Kurka
H2O LLM EvalGPT: A Comprehensive Tool for Evaluating Large Language Models

In an era where Large Language Models (LLMs) are rapidly gaining traction for diverse applications,

July 19, 2023 - by Srinivas Neppalli, Abhay Singhal and Michal Malohlava
Testing Large Language Model (LLM) Vulnerabilities Using Adversarial Attacks

Adversarial analysis seeks to explain a machine learning model by understanding locally what changes need

July 19, 2023 - by Kim Montgomery, Pramit Choudhary and Michal Malohlava
Reducing False Positives in Financial Transactions with AutoML

In an increasingly digital world, combating financial fraud is a high-stakes game. However, the systems

July 14, 2023 - by Asghar Ghorbani

Ready to see the platform in action?

Make data and AI deliver meaningful and significant value to your organization with our state-of-the-art AI platform.