O'Reilly logo

Practical Predictive Analytics by Ralph Winters

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Example – simulating if a customer contact will yield a sale

Here is an example that is based upon a business estimate that one of three customer contacts will result in a sale. Another assumption is that if a sale is made, it will result in an average of $100 each with a standard deviation of $5.

ExpectedPayoff either produces 0 revenue or a figure that hovers around $100, as specified in line 5 of the following code:

library(ggplot2) set.seed(123) CustomerAcquired.Flag <- sample(c(0,0,1), 100, replace = TRUE) Revenue <- sample(rnorm(100,100,5)) ExpectedPayoff <- CustomerAcquired.Flag*Revenue head(ExpectedPayoff) PayoffCompare = ggplot(data.frame(ExpectedPayoff), aes(x=ExpectedPayoff)) + stat_bin(binwidth=5, position="identity") PayoffCompare ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required