fbt-walkthrough

Frequently bought together

In this example, we’ll walk through building a ‘Frequently bought together’ feature to show in a mobile e-commerce app.

Mockup

When a user views a ‘Simple Plant’ in our e-commerce app, we want to promote a set of products to encourage the user to spend more and hence increase the transaction value.

Therefore, the model that we’d like to build is:

Given a product listing, a set of frequently bought together products and a specific user, predict the transaction value.

Let’s say that we’re looking for the following features to train our initial model:

  1. The product listing (product_primary)

  2. Frequently bought together products (fbt_1, fbt_2, fbt_3)

  3. Sessions in the past week (session_index)

  4. Days since install (days_since_install)

  5. User’s age (age)

  6. User’s gender (gender)

  7. User’s country (country)

  8. User’s spend so far (spend_to_date)

and we will predict

  1. User's spend in the current session (transaction_value_this_session)

Once we’ve trained and deployed the model, we query it with the model features and it returns a prediction for the transaction value in this session.

Model query overview

Doing it this way allows us to query the model multiple times with different fbt_* products, and use the ones that result in the highest transaction_value_this_session.

Model query option1
Model query option1

The model predicts a higher transaction_value_this_session for simple_plant, complex_plant and plant_food, so we’ll show that to the user instead of simple_plant, pot and watering_can.

Raw data

We're assuming that we have the following raw data. These events are based on the Firebase SDK.

Session start event

Product page is viewed

Purchase

Transforming data

To train the model, we are looking for data to be organized like this.

Unique user_id (appInstanceId)

product_primary

fbt_1

fbt_2

fbt_3

session_index

days_since_install

age

gender

country

spend_to_date

transaction_value_this_session

Since user may not buy everything in one transaction, fbt_1, fbt_2, fbt_3 are the top 3 products bought by the user in a 48 hour window (+- 24 hours) from the product_primary

Anchor

Streaming BTS

Window BTS

Last updated