library(C50)

data(churn)

treeModel <- C5.0(x = churnTrain[, -20], y = churnTrain$churn)
treeModel
summary(treeModel)
plot(treeModel)


ruleModel <- C5.0(churn ~ ., data = churnTrain, rules = TRUE)
ruleModel
summary(ruleModel)


treeModel <- C5.0(x = churnTrain[, -20], y = churnTrain$churn, control = C5.0Control(winnow = TRUE))
summary(treeModel)
plot(treeModel)


c5.0tree <- C5.0(churn~.,data=churnTrain,trials=5,control=C5.0Control(winnow = TRUE,CF=0.25))
summary(c5.0tree)
plot(c5.0tree)


tc <- C5.0Control(subset =F,CF=0.25,winnow=F,noGlobalPruning=F,minCases =20)
model <- C5.0(churn ~ ., data = churnTrain,rules=F,control =tc)
summary(model)
plot(model)
C5imp(model)
library(C50)

data(churn)

treeModel <- C5.0(x = churnTrain[, -20], y = churnTrain$churn)
treeModel
## 
## Call:
## C5.0.default(x = churnTrain[, -20], y = churnTrain$churn)
## 
## Classification Tree
## Number of samples: 3333 
## Number of predictors: 19 
## 
## Tree size: 27 
## 
## Non-standard options: attempt to group attributes
summary(treeModel)
## 
## Call:
## C5.0.default(x = churnTrain[, -20], y = churnTrain$churn)
## 
## 
## C5.0 [Release 2.07 GPL Edition]      Tue Aug 29 19:57:51 2017
## -------------------------------
## 
## Class specified by attribute `outcome'
## 
## Read 3333 cases (20 attributes) from undefined.data
## 
## Decision tree:
## 
## total_day_minutes > 264.4:
## :...voice_mail_plan = yes:
## :   :...international_plan = no: no (45/1)
## :   :   international_plan = yes: yes (8/3)
## :   voice_mail_plan = no:
## :   :...total_eve_minutes > 187.7:
## :       :...total_night_minutes > 126.9: yes (94/1)
## :       :   total_night_minutes <= 126.9:
## :       :   :...total_day_minutes <= 277: no (4)
## :       :       total_day_minutes > 277: yes (3)
## :       total_eve_minutes <= 187.7:
## :       :...total_eve_charge <= 12.26: no (15/1)
## :           total_eve_charge > 12.26:
## :           :...total_day_minutes <= 277:
## :               :...total_night_minutes <= 224.8: no (13)
## :               :   total_night_minutes > 224.8: yes (5/1)
## :               total_day_minutes > 277:
## :               :...total_night_minutes > 151.9: yes (18)
## :                   total_night_minutes <= 151.9:
## :                   :...account_length <= 123: no (4)
## :                       account_length > 123: yes (2)
## total_day_minutes <= 264.4:
## :...number_customer_service_calls > 3:
##     :...total_day_minutes <= 160.2:
##     :   :...total_eve_charge <= 19.83: yes (79/3)
##     :   :   total_eve_charge > 19.83:
##     :   :   :...total_day_minutes <= 120.5: yes (10)
##     :   :       total_day_minutes > 120.5: no (13/3)
##     :   total_day_minutes > 160.2:
##     :   :...total_eve_charge > 12.05: no (130/24)
##     :       total_eve_charge <= 12.05:
##     :       :...total_eve_calls <= 125: yes (16/2)
##     :           total_eve_calls > 125: no (3)
##     number_customer_service_calls <= 3:
##     :...international_plan = yes:
##         :...total_intl_calls <= 2: yes (51)
##         :   total_intl_calls > 2:
##         :   :...total_intl_minutes <= 13.1: no (173/7)
##         :       total_intl_minutes > 13.1: yes (43)
##         international_plan = no:
##         :...total_day_minutes <= 223.2: no (2221/60)
##             total_day_minutes > 223.2:
##             :...total_eve_charge <= 20.5: no (295/22)
##                 total_eve_charge > 20.5:
##                 :...voice_mail_plan = yes: no (20)
##                     voice_mail_plan = no:
##                     :...total_night_minutes > 174.2: yes (50/8)
##                         total_night_minutes <= 174.2:
##                         :...total_day_minutes <= 246.6: no (12)
##                             total_day_minutes > 246.6:
##                             :...total_day_charge <= 43.33: yes (4)
##                                 total_day_charge > 43.33: no (2)
## 
## 
## Evaluation on training data (3333 cases):
## 
##      Decision Tree   
##    ----------------  
##    Size      Errors  
## 
##      27  136( 4.1%)   <<
## 
## 
##     (a)   (b)    <-classified as
##    ----  ----
##     365   118    (a): class yes
##      18  2832    (b): class no
## 
## 
##  Attribute usage:
## 
##  100.00% total_day_minutes
##   93.67% number_customer_service_calls
##   87.73% international_plan
##   20.73% total_eve_charge
##    8.97% voice_mail_plan
##    8.01% total_intl_calls
##    6.48% total_intl_minutes
##    6.33% total_night_minutes
##    4.74% total_eve_minutes
##    0.57% total_eve_calls
##    0.18% account_length
##    0.18% total_day_charge
## 
## 
## Time: 0.1 secs
plot(treeModel)

ruleModel <- C5.0(churn ~ ., data = churnTrain, rules = TRUE)
ruleModel
## 
## Call:
## C5.0.formula(formula = churn ~ ., data = churnTrain, rules = TRUE)
## 
## Rule-Based Model
## Number of samples: 3333 
## Number of predictors: 19 
## 
## Number of Rules: 19 
## 
## Non-standard options: attempt to group attributes
summary(ruleModel)
## 
## Call:
## C5.0.formula(formula = churn ~ ., data = churnTrain, rules = TRUE)
## 
## 
## C5.0 [Release 2.07 GPL Edition]      Tue Aug 29 19:57:53 2017
## -------------------------------
## 
## Class specified by attribute `outcome'
## 
## Read 3333 cases (20 attributes) from undefined.data
## 
## Rules:
## 
## Rule 1: (60, lift 6.8)
##  international_plan = yes
##  total_intl_calls <= 2
##  ->  class yes  [0.984]
## 
## Rule 2: (57, lift 6.8)
##  international_plan = yes
##  total_intl_minutes > 13.1
##  ->  class yes  [0.983]
## 
## Rule 3: (32, lift 6.7)
##  total_day_minutes <= 120.5
##  number_customer_service_calls > 3
##  ->  class yes  [0.971]
## 
## Rule 4: (79/3, lift 6.6)
##  total_day_minutes <= 160.2
##  total_eve_charge <= 19.83
##  number_customer_service_calls > 3
##  ->  class yes  [0.951]
## 
## Rule 5: (43/2, lift 6.4)
##  international_plan = no
##  voice_mail_plan = no
##  total_day_minutes > 246.6
##  total_eve_charge > 20.5
##  ->  class yes  [0.933]
## 
## Rule 6: (28/2, lift 6.2)
##  total_day_minutes <= 264.4
##  total_eve_calls <= 125
##  total_eve_charge <= 12.05
##  number_customer_service_calls > 3
##  ->  class yes  [0.900]
## 
## Rule 7: (78/8, lift 6.1)
##  voice_mail_plan = no
##  total_day_minutes > 223.2
##  total_eve_charge > 20.5
##  total_night_minutes > 174.2
##  ->  class yes  [0.888]
## 
## Rule 8: (114/24, lift 5.4)
##  voice_mail_plan = no
##  total_day_minutes > 223.2
##  total_eve_charge > 20.5
##  ->  class yes  [0.784]
## 
## Rule 9: (152/58, lift 4.3)
##  total_day_minutes > 223.2
##  total_eve_charge > 20.5
##  ->  class yes  [0.617]
## 
## Rule 10: (211/84, lift 4.1)
##  total_day_minutes > 264.4
##  ->  class yes  [0.601]
## 
## Rule 11: (2221/60, lift 1.1)
##  international_plan = no
##  total_day_minutes <= 223.2
##  number_customer_service_calls <= 3
##  ->  class no  [0.973]
## 
## Rule 12: (768/20, lift 1.1)
##  international_plan = no
##  voice_mail_plan = yes
##  number_customer_service_calls <= 3
##  ->  class no  [0.973]
## 
## Rule 13: (140/5, lift 1.1)
##  account_length <= 123
##  total_eve_minutes <= 187.7
##  total_night_minutes <= 151.9
##  ->  class no  [0.958]
## 
## Rule 14: (45/1, lift 1.1)
##  international_plan = no
##  voice_mail_plan = yes
##  total_day_minutes > 264.4
##  ->  class no  [0.957]
## 
## Rule 15: (1972/87, lift 1.1)
##  total_day_minutes <= 264.4
##  total_intl_minutes <= 13.1
##  total_intl_calls > 2
##  number_customer_service_calls <= 3
##  ->  class no  [0.955]
## 
## Rule 16: (197/9, lift 1.1)
##  total_day_minutes > 120.5
##  total_day_minutes <= 160.2
##  total_eve_charge > 19.83
##  ->  class no  [0.950]
## 
## Rule 17: (155/10, lift 1.1)
##  voice_mail_plan = no
##  total_day_minutes <= 277
##  total_night_minutes <= 126.9
##  ->  class no  [0.930]
## 
## Rule 18: (1675/185, lift 1.0)
##  total_day_minutes > 160.2
##  total_day_minutes <= 264.4
##  total_eve_charge > 12.05
##  ->  class no  [0.889]
## 
## Rule 19: (434/49, lift 1.0)
##  total_eve_charge <= 12.26
##  ->  class no  [0.885]
## 
## Default class: no
## 
## 
## Evaluation on training data (3333 cases):
## 
##          Rules     
##    ----------------
##      No      Errors
## 
##      19  146( 4.4%)   <<
## 
## 
##     (a)   (b)    <-classified as
##    ----  ----
##     371   112    (a): class yes
##      34  2816    (b): class no
## 
## 
##  Attribute usage:
## 
##   98.23% total_day_minutes
##   84.61% number_customer_service_calls
##   75.73% international_plan
##   71.83% total_eve_charge
##   60.97% total_intl_calls
##   60.88% total_intl_minutes
##   31.02% voice_mail_plan
##   10.11% total_night_minutes
##    4.20% account_length
##    4.20% total_eve_minutes
##    0.84% total_eve_calls
## 
## 
## Time: 0.1 secs
treeModel <- C5.0(x = churnTrain[, -20], y = churnTrain$churn, control = C5.0Control(winnow = TRUE))
summary(treeModel)
## 
## Call:
## C5.0.default(x = churnTrain[, -20], y = churnTrain$churn, control
##  = C5.0Control(winnow = TRUE))
## 
## 
## C5.0 [Release 2.07 GPL Edition]      Tue Aug 29 19:57:54 2017
## -------------------------------
## 
## Class specified by attribute `outcome'
## 
## Read 3333 cases (20 attributes) from undefined.data
## 
## 4 attributes winnowed
## Estimated importance of remaining attributes:
## 
##      51%  total_day_minutes
##      40%  international_plan
##      32%  total_eve_charge
##      25%  voice_mail_plan
##      22%  number_customer_service_calls
##      20%  total_intl_calls
##      18%  total_intl_minutes
##      16%  total_day_charge
##       9%  total_eve_minutes
##      <1%  state
##      <1%  account_length
##      <1%  area_code
##      <1%  total_eve_calls
##      <1%  total_night_minutes
##      <1%  total_night_calls
## 
## Decision tree:
## 
## total_day_minutes > 264.4:
## :...voice_mail_plan = yes:
## :   :...international_plan = no: no (45/1)
## :   :   international_plan = yes: yes (8/3)
## :   voice_mail_plan = no:
## :   :...total_eve_minutes > 187.7:
## :       :...total_night_minutes > 126.9: yes (94/1)
## :       :   total_night_minutes <= 126.9:
## :       :   :...total_day_minutes <= 277: no (4)
## :       :       total_day_minutes > 277: yes (3)
## :       total_eve_minutes <= 187.7:
## :       :...total_eve_charge <= 12.26: no (15/1)
## :           total_eve_charge > 12.26:
## :           :...total_day_minutes <= 277:
## :               :...total_night_minutes <= 224.8: no (13)
## :               :   total_night_minutes > 224.8: yes (5/1)
## :               total_day_minutes > 277:
## :               :...total_night_minutes > 151.9: yes (18)
## :                   total_night_minutes <= 151.9:
## :                   :...account_length <= 123: no (4)
## :                       account_length > 123: yes (2)
## total_day_minutes <= 264.4:
## :...number_customer_service_calls > 3:
##     :...total_day_minutes <= 160.2:
##     :   :...total_eve_charge <= 19.83: yes (79/3)
##     :   :   total_eve_charge > 19.83:
##     :   :   :...total_day_minutes <= 120.5: yes (10)
##     :   :       total_day_minutes > 120.5: no (13/3)
##     :   total_day_minutes > 160.2:
##     :   :...total_eve_charge > 12.05: no (130/24)
##     :       total_eve_charge <= 12.05:
##     :       :...total_eve_calls <= 125: yes (16/2)
##     :           total_eve_calls > 125: no (3)
##     number_customer_service_calls <= 3:
##     :...international_plan = yes:
##         :...total_intl_calls <= 2: yes (51)
##         :   total_intl_calls > 2:
##         :   :...total_intl_minutes <= 13.1: no (173/7)
##         :       total_intl_minutes > 13.1: yes (43)
##         international_plan = no:
##         :...total_day_minutes <= 223.2: no (2221/60)
##             total_day_minutes > 223.2:
##             :...total_eve_charge <= 20.5: no (295/22)
##                 total_eve_charge > 20.5:
##                 :...voice_mail_plan = yes: no (20)
##                     voice_mail_plan = no:
##                     :...total_night_minutes > 174.2: yes (50/8)
##                         total_night_minutes <= 174.2:
##                         :...total_day_minutes <= 246.6: no (12)
##                             total_day_minutes > 246.6:
##                             :...total_day_charge <= 43.33: yes (4)
##                                 total_day_charge > 43.33: no (2)
## 
## 
## Evaluation on training data (3333 cases):
## 
##      Decision Tree   
##    ----------------  
##    Size      Errors  
## 
##      27  136( 4.1%)   <<
## 
## 
##     (a)   (b)    <-classified as
##    ----  ----
##     365   118    (a): class yes
##      18  2832    (b): class no
## 
## 
##  Attribute usage:
## 
##  100.00% total_day_minutes
##   93.67% number_customer_service_calls
##   87.73% international_plan
##   20.73% total_eve_charge
##    8.97% voice_mail_plan
##    8.01% total_intl_calls
##    6.48% total_intl_minutes
##    6.33% total_night_minutes
##    4.74% total_eve_minutes
##    0.57% total_eve_calls
##    0.18% account_length
##    0.18% total_day_charge
## 
## 
## Time: 0.1 secs
plot(treeModel)

c5.0tree <- C5.0(churn~.,data=churnTrain,trials=5,control=C5.0Control(winnow = TRUE,CF=0.25))
summary(c5.0tree)
## 
## Call:
## C5.0.formula(formula = churn ~ ., data = churnTrain, trials = 5, control
##  = C5.0Control(winnow = TRUE, CF = 0.25))
## 
## 
## C5.0 [Release 2.07 GPL Edition]      Tue Aug 29 19:57:56 2017
## -------------------------------
## 
## Class specified by attribute `outcome'
## 
## Read 3333 cases (20 attributes) from undefined.data
## 
## 4 attributes winnowed
## Estimated importance of remaining attributes:
## 
##      51%  total_day_minutes
##      40%  international_plan
##      32%  total_eve_charge
##      25%  voice_mail_plan
##      22%  number_customer_service_calls
##      20%  total_intl_calls
##      18%  total_intl_minutes
##      16%  total_day_charge
##       9%  total_eve_minutes
##      <1%  state
##      <1%  account_length
##      <1%  area_code
##      <1%  total_eve_calls
##      <1%  total_night_minutes
##      <1%  total_night_calls
## 
## -----  Trial 0:  -----
## 
## Decision tree:
## 
## total_day_minutes > 264.4:
## :...voice_mail_plan = yes:
## :   :...international_plan = no: no (45/1)
## :   :   international_plan = yes: yes (8/3)
## :   voice_mail_plan = no:
## :   :...total_eve_minutes > 187.7:
## :       :...total_night_minutes > 126.9: yes (94/1)
## :       :   total_night_minutes <= 126.9:
## :       :   :...total_day_minutes <= 277: no (4)
## :       :       total_day_minutes > 277: yes (3)
## :       total_eve_minutes <= 187.7:
## :       :...total_eve_charge <= 12.26: no (15/1)
## :           total_eve_charge > 12.26:
## :           :...total_day_minutes <= 277:
## :               :...total_night_minutes <= 224.8: no (13)
## :               :   total_night_minutes > 224.8: yes (5/1)
## :               total_day_minutes > 277:
## :               :...total_night_minutes > 151.9: yes (18)
## :                   total_night_minutes <= 151.9:
## :                   :...account_length <= 123: no (4)
## :                       account_length > 123: yes (2)
## total_day_minutes <= 264.4:
## :...number_customer_service_calls > 3:
##     :...total_day_minutes <= 160.2:
##     :   :...total_eve_charge <= 19.83: yes (79/3)
##     :   :   total_eve_charge > 19.83:
##     :   :   :...total_day_minutes <= 120.5: yes (10)
##     :   :       total_day_minutes > 120.5: no (13/3)
##     :   total_day_minutes > 160.2:
##     :   :...total_eve_charge > 12.05: no (130/24)
##     :       total_eve_charge <= 12.05:
##     :       :...total_eve_calls <= 125: yes (16/2)
##     :           total_eve_calls > 125: no (3)
##     number_customer_service_calls <= 3:
##     :...international_plan = yes:
##         :...total_intl_calls <= 2: yes (51)
##         :   total_intl_calls > 2:
##         :   :...total_intl_minutes <= 13.1: no (173/7)
##         :       total_intl_minutes > 13.1: yes (43)
##         international_plan = no:
##         :...total_day_minutes <= 223.2: no (2221/60)
##             total_day_minutes > 223.2:
##             :...total_eve_charge <= 20.5: no (295/22)
##                 total_eve_charge > 20.5:
##                 :...voice_mail_plan = yes: no (20)
##                     voice_mail_plan = no:
##                     :...total_night_minutes > 174.2: yes (50/8)
##                         total_night_minutes <= 174.2:
##                         :...total_day_minutes <= 246.6: no (12)
##                             total_day_minutes > 246.6:
##                             :...total_day_charge <= 43.33: yes (4)
##                                 total_day_charge > 43.33: no (2)
## 
## -----  Trial 1:  -----
## 
## Decision tree:
## 
## number_customer_service_calls > 3:
## :...total_day_minutes <= 188: yes (255.1/52.6)
## :   total_day_minutes > 188: no (135.7/60.8)
## number_customer_service_calls <= 3:
## :...total_day_minutes > 245:
##     :...voice_mail_plan = yes: no (94.7/17.1)
##     :   voice_mail_plan = no:
##     :   :...total_eve_minutes <= 201: no (123.6/47.3)
##     :       total_eve_minutes > 201: yes (187.1/19)
##     total_day_minutes <= 245:
##     :...total_eve_charge > 27.61: yes (45.3/9.9)
##         total_eve_charge <= 27.61:
##         :...state in {AK,AL,AR,HI,IA,IL,KY,MO,NV,OK,OR,TN,WV}: no (527.4/17.5)
##             state in {AZ,CA,CO,CT,DC,DE,FL,GA,ID,IN,KS,LA,MA,MD,ME,MI,MN,MS,MT,
##             :         NC,ND,NE,NH,NJ,NM,NY,OH,PA,RI,SC,SD,TX,UT,VA,VT,WA,WI,WY}:
##             :...total_eve_calls <= 59: no (35)
##                 total_eve_calls > 59:
##                 :...total_intl_minutes <= 4: no (34)
##                     total_intl_minutes > 4:
##                     :...international_plan = yes: no (134.4/56.8)
##                         international_plan = no:
##                         :...number_customer_service_calls > 2: no (220.8/29.5)
##                             number_customer_service_calls <= 2:
##                             :...total_eve_charge <= 10.46: no (67.7)
##                                 total_eve_charge > 10.46:
##                                 :...total_intl_calls > 7: no (138.3/22.2)
##                                     total_intl_calls <= 7:
##                                     :...total_day_minutes > 210.5:
##                                         :...state in {AZ,CO,DC,FL,ID,IN,LA,MD,
##                                         :   :         MN,NC,ND,NE,NH,PA,RI,WA,
##                                         :   :         WY}: no (94.6/2.3)
##                                         :   state in {CA,CT,DE,GA,KS,MA,ME,MI,
##                                         :   :         MS,MT,NJ,NM,NY,OH,SC,SD,
##                                         :   :         TX,UT,VA,VT,WI}:
##                                         :   :...voice_mail_plan = yes: no (44.4/13.3)
##                                         :       voice_mail_plan = no: [S1]
##                                         total_day_minutes <= 210.5:
##                                         :...state in {CT,DE,FL,GA,KS,MA,MD,SC,
##                                             :         VT}: no (178.7)
##                                             state in {AZ,CA,CO,DC,ID,IN,LA,ME,
##                                             :         MI,MN,MS,MT,NC,ND,NE,NH,
##                                             :         NJ,NM,NY,OH,PA,RI,SD,TX,
##                                             :         UT,VA,WA,WI,WY}: [S2]
## 
## SubTree [S1]
## 
## total_night_minutes <= 165.4: no (12.9)
## total_night_minutes > 165.4: yes (159.8/38)
## 
## SubTree [S2]
## 
## total_intl_minutes <= 6.3: no (35.7)
## total_intl_minutes > 6.3:
## :...total_day_minutes > 203.6: no (35.7)
##     total_day_minutes <= 203.6:
##     :...total_eve_minutes > 276.3: no (30.4)
##         total_eve_minutes <= 276.3:
##         :...total_night_calls <= 105: no (384.3/86.1)
##             total_night_calls > 105:
##             :...state in {IN,MI,MN,NC,RI,UT,VA}: no (47.9)
##                 state in {AZ,CA,CO,DC,ID,LA,ME,MS,MT,ND,NE,NH,NJ,NM,NY,OH,PA,
##                 :         SD,TX,WA,WI,WY}:
##                 :...total_eve_charge > 20.86: yes (74.1/14.5)
##                     total_eve_charge <= 20.86:
##                     :...state in {CO,NH,NJ,NM,TX,WI}: no (30.4)
##                         state in {AZ,CA,DC,ID,LA,ME,MS,MT,ND,NE,NY,OH,PA,SD,WA,
##                         :         WY}:
##                         :...total_day_minutes <= 131.6: yes (83/16.7)
##                             total_day_minutes > 131.6: no (121.5/53)
## 
## -----  Trial 2:  -----
## 
## Decision tree:
## 
## international_plan = yes:
## :...total_intl_calls <= 2: yes (154)
## :   total_intl_calls > 2:
## :   :...total_intl_minutes > 13.1: yes (116.3)
## :       total_intl_minutes <= 13.1:
## :       :...total_eve_charge <= 26.28: no (181.5/43.7)
## :           total_eve_charge > 26.28: yes (20/4.1)
## international_plan = no:
## :...total_day_minutes > 259.3:
##     :...voice_mail_plan = yes: no (41.6/8.1)
##     :   voice_mail_plan = no:
##     :   :...total_eve_charge <= 13.3: no (25.4/6.7)
##     :       total_eve_charge > 13.3: yes (195.1/28)
##     total_day_minutes <= 259.3:
##     :...number_customer_service_calls > 3:
##         :...state in {AK,AR,CT,ID,KS,KY,MI,MN,MO,MS,MT,NH,NJ,NV,OH,PA,RI,SC,SD,
##         :   :         TN,TX,UT,WA,WV,WY}: yes (193.6/44.1)
##         :   state in {AL,AZ,CA,CO,DC,DE,FL,GA,HI,IA,IL,IN,LA,MA,MD,ME,NC,ND,NE,
##         :             NM,NY,OK,OR,VA,VT,WI}: no (150.5/27)
##         number_customer_service_calls <= 3:
##         :...state in {AK,AL,DE,HI,IA,IL,KY,NV,OK,TN,WV}: no (336/4.7)
##             state in {AR,AZ,CA,CO,CT,DC,FL,GA,ID,IN,KS,LA,MA,MD,ME,MI,MN,MO,MS,
##             :         MT,NC,ND,NE,NH,NJ,NM,NY,OH,OR,PA,RI,SC,SD,TX,UT,VA,VT,WA,
##             :         WI,WY}:
##             :...total_night_minutes <= 120.2: no (70.8)
##                 total_night_minutes > 120.2:
##                 :...total_day_minutes <= 78.3: no (47.5)
##                     total_day_minutes > 78.3:
##                     :...total_eve_calls <= 59: no (30.2)
##                         total_eve_calls > 59:
##                         :...total_eve_charge <= 14.34: no (384.4/72.6)
##                             total_eve_charge > 14.34:
##                             :...total_intl_minutes <= 5.2: no (43.6/2.2)
##                                 total_intl_minutes > 5.2:
##                                 :...total_intl_calls > 9: no (35.5/2.8)
##                                     total_intl_calls <= 9:
##                                     :...total_day_minutes > 247: yes (65.2/24.6)
##                                         total_day_minutes <= 247:
##                                         :...total_eve_calls <= 73: yes (107.8/48.9)
##                                             total_eve_calls > 73:
##                                             :...state in {AR,AZ,CO,CT,GA,MA,MD,
##                                                 :         OR,SD,VA,VT,WA,
##                                                 :         WY}: no (299/30.1)
##                                                 state in {CA,DC,FL,ID,IN,KS,LA,
##                                                 :         ME,MI,MN,MO,MS,MT,NC,
##                                                 :         ND,NE,NH,NJ,NM,NY,OH,
##                                                 :         PA,RI,SC,TX,UT,WI}:
##                                                 :...total_night_minutes > 241.8: [S1]
##                                                     total_night_minutes <= 241.8: [S2]
## 
## SubTree [S1]
## 
## state in {CA,DC,FL,IN,ME,MN,MO,MS,MT,NC,ND,NE,NJ,NM,OH,TX}: yes (191.2/70.2)
## state in {ID,KS,LA,MI,NH,NY,PA,RI,SC,UT,WI}: no (35.1)
## 
## SubTree [S2]
## 
## account_length <= 91: no (198.8/30.6)
## account_length > 91:
## :...number_customer_service_calls > 2: no (27.8/2.2)
##     number_customer_service_calls <= 2:
##     :...total_night_minutes > 213.4: no (75.9/12.6)
##         total_night_minutes <= 213.4:
##         :...state in {DC,FL,KS,MO,ND,NE,PA,UT}: no (37.9)
##             state in {CA,ID,IN,LA,ME,MI,MN,MS,MT,NC,NH,NJ,NM,NY,OH,RI,SC,TX,WI}:
##             :...total_night_minutes > 212.2: yes (19.3/0.6)
##                 total_night_minutes <= 212.2:
##                 :...total_day_charge <= 38.74: yes (221.2/83.8)
##                     total_day_charge > 38.74: no (27.6/3.4)
## 
## -----  Trial 3:  -----
## 
## Decision tree:
## 
## international_plan = yes:
## :...total_intl_calls <= 2: yes (124.8)
## :   total_intl_calls > 2:
## :   :...total_intl_minutes > 13.1: yes (94.3)
## :       total_intl_minutes <= 13.1:
## :       :...state in {AK,AL,CA,CT,DC,FL,HI,IA,ID,IL,IN,KY,LA,MA,MI,MN,MO,NC,ND,
## :           :         NE,NH,NJ,NV,NY,OK,OR,PA,SC,SD,UT,WA,WV,
## :           :         WY}: no (75.4)
## :           state in {AR,AZ,CO,DE,GA,KS,MD,ME,MS,MT,NM,OH,RI,TN,TX,VA,VT,
## :                     WI}: yes (121.2/45.3)
## international_plan = no:
## :...number_customer_service_calls > 3:
##     :...total_day_minutes <= 138.7: yes (68.2/3.6)
##     :   total_day_minutes > 138.7:
##     :   :...total_eve_charge <= 16.22: yes (142.3/44.6)
##     :       total_eve_charge > 16.22:
##     :       :...total_day_minutes <= 241: no (166.7/26)
##     :           total_day_minutes > 241: yes (43.6/9.4)
##     number_customer_service_calls <= 3:
##     :...total_day_minutes > 221.8:
##         :...total_eve_charge > 22.69: yes (80.2/13.3)
##         :   total_eve_charge <= 22.69:
##         :   :...total_day_charge > 48.26: yes (62.8/11.6)
##         :       total_day_charge <= 48.26:
##         :       :...total_night_minutes <= 166: no (98.1/3.5)
##         :           total_night_minutes > 166:
##         :           :...total_day_minutes > 259.3: yes (97/37)
##         :               total_day_minutes <= 259.3:
##         :               :...state in {AK,AL,CO,DC,DE,GA,HI,IA,IL,IN,KY,LA,MA,
##         :                   :         ME,MO,MS,MT,NC,NE,NH,NM,OK,PA,RI,SD,TN,
##         :                   :         TX,UT,VA,VT,WV,WY}: no (140.1/1)
##         :                   state in {AR,AZ,CA,CT,FL,ID,KS,MD,MI,MN,ND,NJ,NV,
##         :                   :         NY,OH,OR,SC,WA,WI}:
##         :                   :...total_night_calls <= 85: yes (55.4/9.1)
##         :                       total_night_calls > 85: no (149.7/55.8)
##         total_day_minutes <= 221.8:
##         :...state in {AK,AL,AR,CT,DE,FL,HI,IA,IL,KS,KY,MA,NV,OK,OR,SD,TN,WV,
##             :         WY}: no (438)
##             state in {AZ,CA,CO,DC,GA,ID,IN,LA,MD,ME,MI,MN,MO,MS,MT,NC,ND,NE,NH,
##             :         NJ,NM,NY,OH,PA,RI,SC,TX,UT,VA,VT,WA,WI}:
##             :...total_eve_charge <= 14.34: no (200.2/6.6)
##                 total_eve_charge > 14.34:
##                 :...voice_mail_plan = yes: no (333.1/61)
##                     voice_mail_plan = no:
##                     :...state in {CA,ID,MN,ND,NH,NM,PA}: no (138.4)
##                         state in {AZ,CO,DC,GA,IN,LA,MD,ME,MI,MO,MS,MT,NC,NE,NJ,
##                         :         NY,OH,RI,SC,TX,UT,VA,VT,WA,WI}:
##                         :...total_night_minutes <= 145.1: no (64.7)
##                             total_night_minutes > 145.1:
##                             :...total_intl_calls > 6: no (80.4/13.1)
##                                 total_intl_calls <= 6:
##                                 :...total_night_calls > 115: no (164/80.2)
##                                     total_night_calls <= 115:
##                                     :...state in {AZ,CO,GA,LA,MO,NY,OH,
##                                         :         WI}: no (86.1)
##                                         state in {DC,IN,MD,ME,MI,MS,MT,NC,NE,
##                                         :         NJ,RI,SC,TX,UT,VA,VT,WA}:
##                                         :...total_day_charge <= 35.65: no (248.1/78.6)
##                                             total_day_charge > 35.65: yes (49.2/14.4)
## 
## -----  Trial 4:  -----
## 
## Decision tree:
## 
## number_customer_service_calls > 3:
## :...total_day_charge > 30.63:
## :   :...total_eve_minutes <= 241.8: no (227/39.1)
## :   :   total_eve_minutes > 241.8: yes (60.1/20.3)
## :   total_day_charge <= 30.63:
## :   :...total_eve_charge <= 16.22: yes (83.8)
## :       total_eve_charge > 16.22:
## :       :...total_eve_charge <= 21.25: yes (141.9/47.1)
## :           total_eve_charge > 21.25: no (40.5/6.6)
## number_customer_service_calls <= 3:
## :...international_plan = yes:
##     :...total_intl_calls <= 2: yes (82.3)
##     :   total_intl_calls > 2:
##     :   :...total_intl_minutes <= 13.1: no (297.3/45.9)
##     :       total_intl_minutes > 13.1: yes (66.5)
##     international_plan = no:
##     :...total_day_minutes <= 209.2:
##         :...state in {AK,AL,AR,CA,CT,DC,DE,FL,GA,HI,IA,ID,IL,IN,KS,KY,LA,MA,MD,
##         :   :         MI,MN,NC,NV,NY,OK,OR,PA,SC,SD,TN,UT,VA,VT,WA,WV,
##         :   :         WY}: no (700.9)
##         :   state in {AZ,CO,ME,MO,MS,MT,ND,NE,NH,NJ,NM,OH,RI,TX,WI}:
##         :   :...total_night_calls <= 105: no (242.8/7.1)
##         :       total_night_calls > 105:
##         :       :...total_intl_calls > 6: no (29.6)
##         :           total_intl_calls <= 6:
##         :           :...number_customer_service_calls <= 0: no (46.8/7.1)
##         :               number_customer_service_calls > 0:
##         :               :...total_eve_minutes <= 245.4: no (117.3/35.6)
##         :                   total_eve_minutes > 245.4: yes (103.8/32.6)
##         total_day_minutes > 209.2:
##         :...voice_mail_plan = yes: no (283.2/5.4)
##             voice_mail_plan = no:
##             :...total_eve_charge > 21.02: yes (163.1/44.1)
##                 total_eve_charge <= 21.02:
##                 :...total_day_minutes <= 245: no (293.8/51.1)
##                     total_day_minutes > 245:
##                     :...total_day_minutes > 301.7: yes (22.1)
##                         total_day_minutes <= 301.7:
##                         :...total_eve_charge <= 14.65: no (92.1/5.9)
##                             total_eve_charge > 14.65:
##                             :...total_night_minutes <= 214.9: no (114.5/42.4)
##                                 total_night_minutes > 214.9: yes (79.5/9.1)
## 
## 
## Evaluation on training data (3333 cases):
## 
## Trial        Decision Tree   
## -----      ----------------  
##    Size      Errors  
## 
##    0     27  136( 4.1%)
##    1     27  377(11.3%)
##    2     28  502(15.1%)
##    3     25  297( 8.9%)
##    4     21  236( 7.1%)
## boost             83( 2.5%)   <<
## 
## 
##     (a)   (b)    <-classified as
##    ----  ----
##     415    68    (a): class yes
##      15  2835    (b): class no
## 
## 
##  Attribute usage:
## 
##  100.00% international_plan
##  100.00% total_day_minutes
##  100.00% number_customer_service_calls
##   99.52% total_eve_charge
##   92.53% state
##   69.55% total_night_minutes
##   67.75% total_intl_minutes
##   67.63% total_eve_calls
##   63.31% total_intl_calls
##   53.20% voice_mail_plan
##   35.70% total_night_calls
##   34.23% total_eve_minutes
##   34.05% total_day_charge
##   17.85% account_length
## 
## 
## Time: 0.3 secs
plot(c5.0tree)

tc <- C5.0Control(subset =F,CF=0.25,winnow=F,noGlobalPruning=F,minCases =20)
model <- C5.0(churn ~ ., data = churnTrain,rules=F,control =tc)
summary(model)
## 
## Call:
## C5.0.formula(formula = churn ~ ., data = churnTrain, rules = F, control
##  = tc)
## 
## 
## C5.0 [Release 2.07 GPL Edition]      Tue Aug 29 19:57:59 2017
## -------------------------------
## 
## Class specified by attribute `outcome'
## 
## Read 3333 cases (20 attributes) from undefined.data
## 
## Decision tree:
## 
## total_day_minutes > 264.4:
## :...voice_mail_plan = yes: no (53/6)
## :   voice_mail_plan = no:
## :   :...total_eve_minutes > 187.7: yes (101/5)
## :       total_eve_minutes <= 187.7:
## :       :...total_day_minutes <= 277.5: no (25/4)
## :           total_day_minutes > 277.5: yes (32/11)
## total_day_minutes <= 264.4:
## :...number_customer_service_calls > 3:
##     :...total_day_minutes <= 160.2: yes (102/13)
##     :   total_day_minutes > 160.2:
##     :   :...total_eve_charge <= 13.22: yes (29/11)
##     :       total_eve_charge > 13.22: no (120/20)
##     number_customer_service_calls <= 3:
##     :...international_plan = yes:
##         :...total_intl_calls <= 2: yes (51)
##         :   total_intl_calls > 2:
##         :   :...total_intl_minutes <= 13.1: no (173/7)
##         :       total_intl_minutes > 13.1: yes (43)
##         international_plan = no:
##         :...total_day_minutes <= 223.2: no (2221/60)
##             total_day_minutes > 223.2:
##             :...total_eve_charge <= 20.5: no (295/22)
##                 total_eve_charge > 20.5:
##                 :...voice_mail_plan = no: yes (68/22)
##                     voice_mail_plan = yes: no (20)
## 
## 
## Evaluation on training data (3333 cases):
## 
##      Decision Tree   
##    ----------------  
##    Size      Errors  
## 
##      14  181( 5.4%)   <<
## 
## 
##     (a)   (b)    <-classified as
##    ----  ----
##     364   119    (a): class yes
##      62  2788    (b): class no
## 
## 
##  Attribute usage:
## 
##  100.00% total_day_minutes
##   93.67% number_customer_service_calls
##   86.14% international_plan
##   15.96% total_eve_charge
##    8.97% voice_mail_plan
##    8.01% total_intl_calls
##    6.48% total_intl_minutes
##    4.74% total_eve_minutes
## 
## 
## Time: 0.1 secs
plot(model)

C5imp(model)
##                               Overall
## total_day_minutes              100.00
## number_customer_service_calls   93.67
## international_plan              86.14
## total_eve_charge                15.96
## voice_mail_plan                  8.97
## total_intl_calls                 8.01
## total_intl_minutes               6.48
## total_eve_minutes                4.74
## state                            0.00
## account_length                   0.00
## area_code                        0.00
## number_vmail_messages            0.00
## total_day_calls                  0.00
## total_day_charge                 0.00
## total_eve_calls                  0.00
## total_night_minutes              0.00
## total_night_calls                0.00
## total_night_charge               0.00
## total_intl_charge                0.00