Question



Computing Probabilities manually with Bayes Theorem.

Professor Ballings,
In the exercise 2.5.2, we are asked to find the probability of Churn = 1, when tenure = “medium” and “spend” is
high.

The example given in the book is pretty straight forward, but as you can see below, there are zero observations when tenure =
“medium” and
Spend = “high.”

So when I get to this part of the book example:
NB <- naiveBayes(x=df[,2:3], y=df[,1])
(predNB <- predict(NB,df[1,2:3], type = "raw", threshold = 0.001)[,2])

I’m not exactly sure what I’m supposed to do, because the df[1,2:3] - The 1 is representing the row observation
“long” “high”, and since there
Is not an observation of “medium” “high” that we are supposed to look for, how do we then approach this
problem…….

Is this a mistake, or something we need to work through?

Thanks,

Bryan A. Sharpe

##############################################################################

#2.8.3 Exercises for Subsection 2.5.2 P.184
#This is a question about naive Bayes. Consider the following dataset.

#What is the probability
#of churn = 1 for a new instance that has tenure = "medium" and spend = "high"?
#The code chunk below is available from http://ballings.co/hidden/aCRM/code/
#chapter2/ex_nb.R
##############################################################################
(df <-
data.frame(
churn=c(0,0,1,1,1,0,1,0,1,1,1,1,1,0),
tenure=c("long","long","short","medium",
"medium","medium","short","long",
"long","medium","long","short",
"short","medium"),
spend=c("high","high","high","medium"
,"low","low","low","medium",
"low","medium","medium","medium",
"high","medium")))
churn tenure spend
1 0 long high
2 0 long high
3 1 short high
4 1 medium medium
5 1 medium low
6 0 medium low
7 1 short low
8 0 long medium
9 1 long low
10 1 medium medium
11 1 long medium
12 1 short medium
13 1 short high
14 0 medium medium






Answers and follow-up questions





Answer or follow-up question 1

Dear Bryan,

You need to compute it manually like we did in class.

To see how to check if you've done it correctly:
http://www.ballings.co/qa/question.php?nbr=56

Michel Ballings







Sign in to be able to add an answer or mark this question as resolved.