Los profesores son poco ortodoxos.

Hace poco mi hija de 14 años me contó que su profesora de historia empezó a gritarle a un alumno nuevo y le sacó de la clase. Este artículo forma parte de la colección “experiencias Creanova” en la…

Smartphone

独家优惠奖金 100% 高达 1 BTC + 180 免费旋转




Finding Effective Offers for Starbucks Rewards Customers

Starbucks Rewards Mobile App
Starbucks Rewards Mobile App

Starbucks rewards mobile app provides promotional offers to its users that can influence their purchasing decisions. These offers are sent based on behavioral patterns of the customers, so not all users receive the same offer. We need to figure out which offer to send to the users.

There are 3 types of offers: buy-one-get-one (BOGO), discount, and informational. In a BOGO offer, a user needs to spend a certain amount to get a reward equal to that threshold amount. In a discount, a user gains a reward equal to a fraction of the amount spent. In an informational offer, there is no reward, but neither is there a requisite amount that the user is expected to spend. To make an effective offer that can be completed by a user, we need to determine which demographic groups respond best to which offer type.

In this project, we are going to build a machine learning project to figure out effective offers for individual customers who are using Starbucks rewards mobile app.

To send effective offers to the customers, we need to build a machine learning model to predict whether an offer can be completed by a customer or not.

Questions to answer:

The dataset that we have do not contain skewed data, and this is going to be a binary classification project so, we can use accuracy score to evaluate our model.

The dataset is provided by Starbucks containing simulated data that mimics customer behavior on the Starbucks rewards mobile app. It is a simplified version of the real Starbucks app because the underlying simulator only has one product.

There are 3 different datasets:

profile.json: Rewards program users (17000 users x 5 fields)

portfolio.json: Offers sent during 30-day test period (10 offers x 6 fields)

transcript.json: Event log (306648 events x 4 fields)

In the transcript dataset, we have good distributions for the offers and event types:

Also, good distributions for age and income fields in the profile dataset:

These 3 datasets are cleaned and pre-processing operations are done on each of them to create a unified view of the data to obtain the input dataset for an ML model.

original sample data
original sample data
original sample data

After this initial preparation of the datasets, we need to understand which fields can be used to build a successful model. To achieve this, user actions need to be understood.

User actions are stored in the transcript dataset. There are 4 types of events like offer received, offer viewed, offer completed and transaction.

An effective offer is the completed one after it is viewed by the relevant customer. Merely completing an offer does not mean if that was an effective offer or not, because an offer can be naturally completed by the routine customer behavior as well. So, expected user action series for an effective offer is in offer viewed -> transaction -> offer completed pattern.

offer received is not a user action and, it can be treated like a system log. So, we can filter out these events from our dataset.

We made an assumption based on user behavior such that we treated transactions within a valid offer period are affected by that offer. We can’t say this for sure, a transaction might be just related to usual user habit, but it can be because of the offer as well. So, we made that assumption and calculated the total transaction amount during the valid offer period. Even if a transaction is not affected by an offer, this assumption can still be valuable since it provides financial info to the model.

We iterated over viewed offers, calculated transaction amounts during their valid period times and checked their completion status. And, we merged our datasets to create the dataset which is going to be the input to our model:

We are going to build a binary classification model to predict if an offer can be completed by a user or not. So, completed is our target column, and the rest of the columns are the features.

We split our dataset into train and test with 30% ratio. We created a pipeline to do feature scaling using StandartScaler and try different models to choose the most successful one easily by the help of cross validation.

Pipeline implementation

Results of these algorithms:

Based on these results, we can say that GradientBoostingClassifier is the most successful one. We also tried this model on our test dataset and got 88% accuracy score.

With standard implementation of the GradientBoostingClassifier , we get pretty good results. When we need to tune our hyper parameters, we can use GridSearch to find out the most efficient parameter setup.

We evaluated our model with the test dataset and got 88% accuracy score which is a pretty good score.

We initially asked 3 questions, and the first one is answered with the above implementation. Let’s look at the left ones.

Q2: Which fields provide the most predictive power?

Q3: Which gender is completing offers the most?

Men are completing offers more than women. Maybe this is because they drink more or they are more careful on following offers.

We made 2 basic assumptions during our data preprocessing steps.

The first one is related to the column when a user became member. We need to know when this dataset is extracted to calculate the time elapsed accurately. Since we don’t know this information, we got the rounded value of the max value of this column.

And, the second one is directly related to our business logic which is assuming transactions existing within valid offer periods are affected from these offers. This assumption is valuable since it inputs financial information to the model but, we can’t say this true for sure.

We used cross validation while building our model so, we eliminated overfitting and used pipeline to find out the best performant model. And, we got pretty good results.

We’ve successfully built the model to predict if an offer is effective for a particular customer or not with 88% test accuracy score. By using the model, we can decide which offer to send to the customer.
And, we answered all our initial questions.

Further data analysis can be done using this dataset like channel-age, income-offer type relationship etc.

In the dataset, we have just one product offers whereas Starbucks sells dozens of products. This implementation does not fit to all other product types. So, it is better to try out this model with different product offers as well.

Also, it would be good if we can capture if a transaction is occurred because of an offer or not to identify which transactions are affected from the offers. Then, we don’t need to make an assumption on that.

I hope you find this post useful, thanks for reading!

Add a comment

Related posts:

Meet the 2020 World Finalists

This is it! Only two teams are left in the tournament, and only one will hoist the Summoner’s Cup in front of an audience of over 6,000 in Shanghai’s Pudong Football Stadium. These two teams have…

Who am I and why do I write?

Hi there! My name is Patty and I’m a 25-year-old married stay at home mama to two-month-old little E. My life has been flipped upside down during the past few months and I’m still adjusting my…

Install ORACLE JDK 8 on Ubuntu

This is the latest stable version of Java 8 at time of writing, and the recommended version to install. You can do so using the following command: Open /etc/environment file with your favorite text…