More Personal to the Customer
Step 1. Build the best possible model
Nienke suggested that you try to build your own cross-sell models for the other products you want to include in the next best offer. Try to first build a couple of trees – or more if you are getting the hang of it!
After you created different decision trees, work with the rank or index method based on your predicted probabilities to determine the next best offer.
(Hint: If you need a little help with these methods, check out the additional material section in the previous unit).
Step 2. Inform your colleagues
Use your model outcomes in a briefing to your colleagues. You want to activate them by showing them the new way of using predictive modelling to derive the Next Best Offer per customer. In this way your company can be more relevant - and thus personal - to the customer. Take them through the most important process-steps.
Next best offer
I have made the nextbest offer using the decision tree for the home insurences (HomeActive). I have made the analysis, but there seems to be a problem with my gainliftchart for the second model. I have tried to locate the error in the code, but I cannot find it.
Here is the code I have used for the gainliftchart (i have also attached the full script).
gainLiftChart( index = 1:length(subvalidationset_home[,1]),
target = subvalidationset_home$HomeActive,
predictions = scoreset_home$predictions_home,
charttitle = "Cumulative gains and lift chart",
nameyaxis = "Gain/Lift",
namexaxis = "% customers selected",
smooth = 10,
secondaxis = 80)
here is the script for the model:
subtrainset_home <- trainSet[c(7:24,26:43)]
Growing the tree
library(rpart)
model1_home <- rpart(HomeActive ~., data = subtrainset_home, method = 'anova')
Visualisering
library(rpart.plot)
prp(model1_home, extra = 101)
Examine variable importance
summary(model1_home)
Et større træ (lavere CP)
model2_home <- rpart(HomeActive ~., data = subtrainset_home, method = 'anova', cp =0.001)
prp(model2_home, extra = 101)
Determine the optimal tree size
printcp(model2_home)
Visualuze the cross-validated results
plotcp(model2_home, upper = "splits" )
Prune back the tree
model3_home <- prune(model2_home, cp =0.001)
prp(model3_home, extra = 101)
Set the minimum bucket (end node) size
model4_home <- rpart(HomeActive ~., data = subtrainset_home, method = 'anova', cp =0.004, minbucket = 100)
prp(model4_home, extra =101)
summary(model4_home)
Check robustness of variable importance
Create a subset of variables that may be included in the decision tree model
subvalidationset_home <- validationSet[c(7:24,26:43)]
Estimate the model on the subValidationSet
valmodel4_home <- rpart(HomeActive ~., data = subvalidationset_home, method = 'anova', cp =0.004, minbucket = 100)
prp(valmodel4_home, extra = 101)
Cumulative gains chart and life chart
predictions_home <- predict(model4_home, newdata = validationSet)
create scoreset
scoreset_home <- data.frame(cbind(predictions_home,validationSet$HomeActive))
plot Gainchart using the Gainchart Function
gainLiftChart( index = 1:length(subvalidationset_home[,1]),
target = subvalidationset_home$HomeActive,
predictions = scoreset_home$predictions_home,
charttitle = "Cumulative gains and lift chart",
nameyaxis = "Gain/Lift",
namexaxis = "% customers selected",
smooth = 10,
secondaxis = 80)