September 6th, 2019

Driverless AI can help you choose what you consume next

RSS icon RSS Category: 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 https://github.com/h2oai/driverlessai-recipes repository. We shall use one of the available recipes to develop a Recommender system with Driverless AI.

Objective

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.

Dataset

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.

Conclusion

Acknowledgments

About the Author

Parul Pandey

Leave a Reply

Make your own AI — Add Your Game to Auto-ML Models

When Features and Algorithms compete, your Business Use Case(s) wins! H2O Driverless AI is an Automatic

October 15, 2019 - by Karthik Guruswamy
H2O World New York: The Countdown is On!

Every H2O World is magical. The preparation for the conference starts many months in advance

October 14, 2019 - by
5 Key Takeaways On Overcoming Gender and Diversity Barriers

Overcoming gender and diversity barriers in the workplace is a challenge for many industries. Therefore,

October 4, 2019 - by
Fallback Featured Image
Predicting Failures from Sensor Data using AI/ML — Part 2

This is Part 2 of the blog post series and continuation of the original post,

September 27, 2019 - by Karthik Guruswamy
H2O Driverless AI: The Workbench for Data Science

This blog was written by Rohan Gupta and originally published here. 1. Introduction In today’s world, being

September 26, 2019 - by Vinod Iyengar
Fallback Featured Image
H2O Driverless AI Acceleration with Intel DAAL

This week at Strata NY 2019 we will be demoing a custom recipe that incorporates

September 25, 2019 - by Rafael Coss

Join the AI Revolution

Subscribe, read the documentation, download or contact us.

Subscribe to the Newsletter

Start Your 21-Day Free Trial Today

Get It Now
Desktop img