Digital Marketing Application Method of Machine Learning and Data Mining, with RFM Model

No matter it is a classifier or a regression model, we apply the data mining and machine learning methods to achieve a target. To be more straightforward, we need to solve a problem.

Especially in Digital Marketing (or “traditional marketing with data analytics approach”) when we focus on models of AARRR, PRAPA or ARM, in each step of this model we can apply suitable data mining even machine learning methods to solve the problem.

When we focus on specific marketing channels or tools, such as SEO/ASO, PPC, Email marketing, Social Marketing and Content Marketing, related models or algorithms can be applied to achieve a promising results to boost performance. The marketing related systems or applications, such as recommendation system or content marketing campaign through email or social media, are actually based on association rules, network analysis/tree analysis or other models which we already are familiar with in machine learning.

When we want to focus on specific KPIs or metrics, such as LTV or Churn rate, it would be convenient to conduct data mining methods on platform like R to evaluate, predict and analyze. These data and numbers are essential for us to understand our customers’ behavior within dimensions of profitability, life-cycle, loyalty, interests and campaigns.

DMAIC

figure-4.pngBack to the first conclusion, everything starts with the problem.

The typical model of problem-solve with data, which actually comes from Lean6sigma area, called DMAIC is applicable here. Define the problem, set up the Measurements or Metrics or even Models, conduct Analysis to define solution, conduct the solution for Improvements, and Control the results to make the outcome sustainable.

For instance, we want to know LTV of our customers.

Define the problem. We do not understand our customers; we do not know how much value can our customers generate for us (after we still believe LTV fits as a metric in the business)

Metrics. ARPU/ARPA (Historic CLV); RFM (only applicable to the next period); CLV Formula (historic CLV); Growth and dissemination models such as: Moving Averages, Regressions, Bayesian Inference, Pareto/NBD (Negative Binomial Distribution) The value generated by all our customers is called Customer Equity and is used to evaluate companies (with no significant income yet). We need to think of the options we have here.

Analyze. This is the step to conduct data analysis, data mining and machine learning. We need to

1. Identification and understanding of sources and metadata

2. Extract, transform, clean and load data

3. Define and build LTV method and model.

4. Analyze results and adjust parameters

5. Consolidate the proposal/recommendation, present and explain the results

Improvements. The basic requirement here to solve the problem we came up with at the very beginning with fulfillment of the metrics we set up.

Besides, we also need to explore the further possibilities brought by  the analysis and this is much more about business side.

In this case, we can think about our ability to create new business objectives; can we set up this numerical analysis criteria as a process or standard; ability to have an alert system; improved management of the sales force.

We can also create market strategies based on LTV; build customer segmentation, forecasting and customer evolution per segment; create different communication, services and loyalty programs; awake “non-active” customers; estimated the value of a company (startup, in the context of acquisition).

Control. To sustain the effect/outcome is not as easy as you may think. Especially when we want to establish a standard process based on what we have done to produce a final outcome regularly and repetitively, a lot of change/risk would happen.

The data source might change, the customers’ preference might change, the competition environment might change and the importance of this KPI might change.

An effective way to fight again risk is to build the FMEA(failure mode effects analysis) model to have a plan B or to set up strategies to deal with risk.

A RFM Model

rfm-analysis-101-300x300.jpg

This model is based on Recency, Frequency, Monetary model. As a example here, we can build a model to launch target campaigns towards to different groups of customers.

For recommendation system: https://charleshsliao.wordpress.com/2017/03/06/an-quick-association-rules-example-within-r/

We can also build target marketing on social media with decision trees and network model to launch targeted marketing; we can also build NPS(net promote score) model to track and improve customers’ satisfaction.

rfm-chart.jpg

</pre>
library(magrittr)
library(dplyr)

##
## Attaching package: 'dplyr'

## The following objects are masked from 'package:stats':
##
##     filter, lag

## The following objects are masked from 'package:base':
##
##     intersect, setdiff, setequal, union

###############################################################
#1.simulate customers' shopping history
# this where we identification and understanding of sources and metadata
sales<-data.frame(sample(1000:1999,replace=T,size=10000),
abs(round(rnorm(10000,28,13))))
names(sales)=c("CustomerId","Sales Value")
# take a look
dplyr::arrange(dplyr::count(sales,CustomerId), desc(n))

## # A tibble: 999 × 2
##    CustomerId     n
##         <int> <int>
## 1        1387    24
## 2        1483    22
## 3        1149    20
## 4        1350    20
## 5        1684    20
## 6        1005    19
## 7        1308    19
## 8        1651    19
## 9        1943    19
## 10       1045    18
## # ... with 989 more rows

dplyr::arrange(dplyr::count(sales,CustomerId),n)

## # A tibble: 999 × 2
##    CustomerId     n
##         <int> <int>
## 1        1146     2
## 2        1858     2
## 3        1228     3
## 4        1368     3
## 5        1460     3
## 6        1501     3
## 7        1522     3
## 8        1560     3
## 9        1602     3
## 10       1636     3
## # ... with 989 more rows

###############################################################
#2.generate random dates
# this is where we extract, transform, clean and load data
sales.dates <- as.Date("2017/1/1") + 700*sort(stats::runif(10000))
sales<-cbind(sales,sales.dates)
str(sales)

## 'data.frame':    10000 obs. of  3 variables:
##  $ CustomerId : int  1730 1936 1275 1149 1783 1385 1862 1807 1058 1619 ...
##  $ Sales Value: num  34 16 27 15 18 37 54 42 38 26 ...
##  $ sales.dates: Date, format: "2017-01-01" "2017-01-01" ...

###############################################################
#3. Build Monetization,Frequency,Last Purchase date for each customer
# this is where we define and build the method and model(RFM model)
sales$recency<-round(as.numeric(difftime(Sys.Date(),sales[,3],units="days")) )
names(sales)<-c("CustomerId", "Purchase.Value", "sales.dates","recency")

sales_M<-aggregate(sales[,2],list(sales$CustomerId),sum)
names(sales_M)<-c("CustomerId","Monetization")

sales_F<-aggregate(sales[,2],list(sales$CustomerId),length)
names(sales_F)<-c("CustomerId","Frequency")

sales_R<-aggregate(sales[,4],list(sales$CustomerId),min)
names(sales_R)=c("CustomerId","Recency")
#Merging R,F,M(like join in SQL)
sales_RF<-merge(sales_F,sales_R,"CustomerId")
sales_RFM<-merge(sales_M,sales_RF,"CustomerId")

##Creating R,F,M levels
sales_RFM$rankR<-cut(sales_RFM$Recency, 12,labels=F)
sales_RFM$rankF<-cut(sales_RFM$Frequency, 12,labels=F)
sales_RFM$rankM<-cut(sales_RFM$Monetization, 12,labels=F)

###############################################################
#4. check RFM tables
# this is where we analyze results and adjust parameters
R_low_F_high_M_high<-filter(sales_RFM,rankR<=6&rankF>=6&rankM>=6)
R_low_F_low_M_low<-filter(sales_RFM,rankR<=6&rankF<=6&rankM<=6)
R_low_F_low_M_high<-filter(sales_RFM,rankR<=6&rankF<=6&rankM>=6)
R_high_F_high_M_high<-filter(sales_RFM,rankR>=6&rankF>=6&rankM>=6)
str(R_low_F_high_M_high)

## 'data.frame':    205 obs. of  7 variables:
##  $ CustomerId  : int  1005 1007 1010 1012 1013 1019 1024 1025 1029 1037 ...
##  $ Monetization: num  580 385 373 389 391 351 509 457 367 376 ...
##  $ Frequency   : int  19 14 12 14 15 14 16 15 13 14 ...
##  $ Recency     : num  -556 -618 -628 -618 -601 -577 -620 -620 -624 -622 ...
##  $ rankR       : int  2 1 1 1 1 2 1 1 1 1 ...
##  $ rankF       : int  10 7 6 7 8 7 8 8 6 7 ...
##  $ rankM       : int  9 6 6 6 6 6 8 7 6 6 ...

str(R_low_F_low_M_low)

## 'data.frame':    810 obs. of  7 variables:
##  $ CustomerId  : int  1000 1001 1002 1003 1004 1006 1008 1009 1010 1011 ...
##  $ Monetization: num  303 220 186 190 181 250 158 293 373 310 ...
##  $ Frequency   : int  8 8 7 8 6 10 8 12 12 10 ...
##  $ Recency     : num  -590 -449 -582 -517 -406 -529 -459 -625 -628 -473 ...
##  $ rankR       : int  2 5 2 3 6 3 5 1 1 5 ...
##  $ rankF       : int  4 4 3 4 3 5 4 6 6 5 ...
##  $ rankM       : int  5 3 3 3 3 4 3 5 6 5 ...

str(R_low_F_low_M_high)

## 'data.frame':    109 obs. of  7 variables:
##  $ CustomerId  : int  1010 1029 1061 1070 1073 1077 1085 1091 1092 1101 ...
##  $ Monetization: num  373 367 376 410 384 374 387 383 361 373 ...
##  $ Frequency   : int  12 13 13 12 9 12 11 13 13 12 ...
##  $ Recency     : num  -628 -624 -462 -626 -584 -585 -612 -615 -550 -591 ...
##  $ rankR       : int  1 1 5 1 2 2 1 1 3 1 ...
##  $ rankF       : int  6 6 6 6 4 6 5 6 6 6 ...
##  $ rankM       : int  6 6 6 6 6 6 6 6 6 6 ...

str(R_high_F_high_M_high)

## 'data.frame':    2 obs. of  7 variables:
##  $ CustomerId  : int  1274 1558
##  $ Monetization: num  379 374
##  $ Frequency   : int  16 12
##  $ Recency     : num  -390 -311
##  $ rankR       : int  7 9
##  $ rankF       : int  8 6
##  $ rankM       : int  6 6

###############################################################
#5. based on this four different groups of custoemrs, target marketing compaigns
# should be executed to increae their LTV, low churn rate and so on.
# This is where we consolidate the proposal/recommendation, present and explain the results.
<pre>
Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s