Product Recommendations using TensorFlow APIs

1–2 minutes

Recommendation systems have different types of filtering types – Content, Collaboration and Hybrid. Though these are the traditional models, they form the basis of future recommendation models. All these filtration models can be using Tensorflow.

Tensorflow is a python library and it includes the TensorFlow Recommender Library. 

Introduction: 

TensorFlow Recommenders (TFRS) is an open source library for building recommender system models.

It helps with the full workflow of building a recommender system: data preparation, model formulation, training, evaluation, and deployment. It’s built on Keras and aims to have a gentle learning curve while still giving you the flexibility to build complex models.

TFRS has a modular structure designed to allow the users to customize individual layers and metrics.

Use Case 1: Building Movie Recommendation using TFRS

To get a feel for how to use TensorFlow Recommenders, let’s start with a simple example. First, install TFRS using pip:

!pip install tensorflow_recommenders

We can then use the MovieLens dataset to train a simple model for movie recommendations. This dataset contains information on what movies a user watched, and what ratings users gave to the movies they watched.

We will use this dataset to build a model to predict which movies a user watched, and which they didn’t. A common and effective pattern for this sort of task is the so-called two-tower model: a neural network with two sub-models that learn representations for queries and candidates separately. The score of a given query-candidate pair is simply the dot product of the outputs of these two towers.

This model architecture is quite flexible. The inputs can be anything: user ids, search queries, or timestamps on the query side; movie titles, descriptions, synopses, lists of starring actors on the candidate side.

In this example, we’re going to keep things simple and stick to user ids for the query tower, and movie titles for the candidate tower.

Discover more from Generative Product Mentoring Lab - Free Masterclasses

Subscribe now to keep reading and get access to the full archive.

Continue reading