Starbucks Corporation is an American multinational chain of coffeehouses. Starbucks sends out an offer to users of the mobile app. An offer can be merely an advertisement for a drink or an actual offer such as a discount or BOGO (buy one get one free) or an informational offer that includes the product information. Not all users receive the same offers during certain weeks. Starbucks would likely build the possibility that Once the customer receives the offers they open it and finish the transaction.
This project is mainly focused on the promotional offers for customers based on their responses to the previous offers and predict the response of a customer to an offer. So that machine learning models can be built to predict whether a customer will respond to an offer or not. So that Starbucks can send offer types in a better way. Therefore, we’ll attempt to break down the Starbucks history dataset to get some understanding of it.
As we discuss here is a real-life marketing strategy study based on the simulated data set that mimics customer behavior on the Starbucks rewards mobile app. You can find the project on my Github repository Starbuck Capstone.
The question that we will answer in this analysis is which demographic groups respond best to which offer type?
Data Exploration and Data Preprocessing
The three datasets that we analyzed need to be combined into one dataset so that we can use them for the exploratory data analysis and model building. Before merging the datasets, there was lots of data wrangling and preprocessing to be done. First, we will prepare the data for EDA, and later pre-processing for fitting it into the model to predict whether a customer will respond to an offer or not.
The file describes the characteristics of each offer, including its duration and the amount a customer needs to spend to complete it.
- id (string): offer id.
- offer_type (string): type of offer i.e. BOGO, discount, informational.
- difficulty (int): minimum required spend to complete an offer.
- reward (int): reward is given for completing an offer.
- duration (int): time for the offer to be open, in days.
- channels (list of strings): channels (mobile, web, email, social)
Rename some columns for better readability & split the data into columns.
The file contains customer demographic data including their age, gender, income, and when they created an account on the Starbucks rewards mobile application.
- age (int): age of the customer.
- became_member_on (int): the date when customers created an app account.
- gender (str): gender of the customers.
- id (str) : customer id.
- income (float) : customer’s income.
In Profile, customers whose age is 118 have abnormalities with the data and missing information. So we are excluding those customers. Rename some of the columns for better readability & ease in merging data frames and classifying ages into groups for better understanding.
The file describes customer purchases and when they received, viewed, and completed an offer. An offer is only successful when a customer both views an offer and meets its difficulty within the offer’s duration.
- event (str): record description (i.e. transaction, offer received, offer viewed, etc.)
- person (str) : customer id.
- time (int): time in hours since the start of the test.
- value (dict of strings): either an offer id or transaction amount depending on the record.
The cleaning and preprocessing of the transcript. Convert time in hours to time in day· Rename some columns for better readability & ease in merging data frames. Process the value column i.e segregate it into different column based on the event column· Segregate offer and transaction data
Merging cleaned data frames
Now, we merge all cleaned data frames so that all the features are contained within one data frame and then apply Exploratory Data Analysis.
Exploratory Data Analysis
To maximize insights into our cleaned data frame and find its interesting characteristic features and representations, we will cover the main points for the combined population to the individual personalized level.
Males were more as compared to others
2. What are the age group of the customer?
3.How the income range varies for each gender?
The average customer income is 66414.12
4.How is the data is divided between different offers?
5.How is the data is divided between different events?
The customer who used the offer is less as compared to the offer received.
6.Which offers were popular in Gender?
Bogo and discount is distributed equally
7.Which offers were liked in the various age groups?
Age_group between 46–80 got more offer type as compared to other Age _group
8. How customers respond to the offer type?
9.How customer responses to the offer type which is received through Email?
10.How customers respond to the offer type which is received through the web?
11. How customer respond to the offer type which is received through Mobile?
12. How customer respond to the offer type which is received through Social?
13. What are the most popular offers in the various age groups?
Customers of age group 46–60 and 61- 80 complete the offer.
14. What is the response to the offers in gender?
Male and Female almost equally complete the offer. As compared to females, Males received more offers.
15. How is the event varying in the various income range?
Customer age between 46–80 and income between 60000–80000 responded most to offers type ‘BOGO’ and then ‘Discount’ So it will be good to send BOGO and Discount offers to these customers.
In the next step, I had created the models to predict whether the customer will respond to the different types of offers or not.
Data Preparation and Cleaning
Before building a model, we’ll have to clean & prepare the data to fit into the model. To do this we will perform some tasks.
Split train and test data
We now have to split the data (both features and their labels) into training and test sets, taking 60% of data for training and 40% for testing.
We plan to implement to use different types of machine learning models are KNeighborsClassifier, RandomForestClassifier, DecisionTreeClassifier, and Gaussian Naive Bayes model.
After using Grid Search with Decision Tree Classifier we managed to get better results as shown here:
After this, we compute the training accuracy and predicting the accuracy of the new model with the best parameters.
The results are:
- Training Accuracy: 92.71%
- Predicting Accuracy: 92.64%
From the original fitting to using the best parameters for fitting we gain almost 7% accuracy which is very good. Even though the accuracy on the training model goes down.
In this project, I explored the dataset, analyzed, visualized, and created supervised machine learning models. Overall, I found this project challenging. I have examined the dataset, evaluated different aspects to gain an overall understanding of the data. After that, I did Pre-processing the Data, where I did wrangling. After that, I did visualization to get an understanding of the offer types and how it is distributed in the dataset. Then I had created a Machine learning Model to predict whether customers complete the offer or not.
- The income of customer is in between 30000 and 120000 where women earn higher range as compared to men.
- Customers with age 118 are mostly either fake entries or abnormalities or customers who did not want to disclose that information. So I drop these during the preprocessing of the dataset.
- Male and Female almost equally complete the offer. As compared to females, Males received more offers. Customers of age group between 46–80 and whose income between 60000–80000 respond most to offers type ‘BOGO’ and then ‘Discount’ So it will be good to send BOGO and Discount offers to these customers.
- I can conclude that the model can predict 92.64% accuracy, what happens when a customer gets an offer.
Although this was an in-depth analysis, there is lots of room for improvement. Here are a few comments:
- There may be overfitting which can be solved by considering more data, in the future.
- Build a Machine Learning Pipeline to seamlessly classify new data.
- For getting more Customers Starbucks can come up with attractive offers for Age group between 20–46.
To see more details on the analysis, you can find my Github link here.