How to graph the model result of C5.0 tree in R.

4,619 views
Skip to first unread message

cy5...@gmail.com

unread,
Mar 12, 2014, 4:24:45 AM3/12/14
to taiwa...@googlegroups.com
Hi Sir,

Could you please instruct me which package can graph the model of C5.0 tree (C50)? I found that PLOT was not workable for C5.0 tree.
Below is the result of my practice. Please take a look and provide your advice.
Thanks a lot in advance.


Best Regards,
CY Wu


> c5.tree <- C5.0(churn~., data=churnTrain, rules=FALSE)

> summary(c5.tree)

 

Call:

C5.0.formula(formula = churn ~ ., data = churnTrain, rules = FALSE)

 

 

C5.0 [Release 2.07 GPL Edition]        Wed Mar 12 15:05:16 2014

-------------------------------

 

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(c5.tree)

Error in xy.coords(x, y, xlabel, ylabel, log) :

  'x' is a list, but does not have components 'x' and 'y'

 


DataScientist

unread,
Mar 12, 2014, 4:54:04 AM3/12/14
to taiwa...@googlegroups.com
Hi,

Sorry! It seems that the package C50 does not provide a plot method for its results. Please refer to the reference manual http://cran.r-project.org/web/packages/C50/C50.pdf. Thanks for your post.

<span lang="EN-US" style='background: rgb(225, 226, 229); color: black; font-family: "Lucida Console"; font-size: 10pt; mso-far

...

Thanos Tsakonas

unread,
Sep 23, 2014, 10:06:30 AM9/23/14
to taiwa...@googlegroups.com

You might consider using the following code: http://r-project-thanos.blogspot.de/2014/09/plot-c50-decision-trees-in-r.html

thanos

cy5...@gmail.com

unread,
Sep 24, 2014, 4:42:12 AM9/24/14
to taiwa...@googlegroups.com
Many thanks for your helps, Thanos.

CY

Thanos Tsakonas於 2014年9月23日星期二UTC+8下午10時06分30秒寫道:

cy5...@gmail.com

unread,
Oct 9, 2014, 3:28:40 AM10/9/14
to taiwa...@googlegroups.com
Hi Thanos, 

When I applied C5.0.graphviz, the error occurred as below.  I just tried the example you showed on http://r-project-thanos.blogspot.tw/2014/09/plot-c50-decision-trees-in-r.html


Error: lazy-load database 'P' is corrupt
In addition: Warning messages:
1: restarting interrupted promise evaluation 
2: internal error -3 in R_decompress1 


Would you please tell me what happen and how to solve it. 
Thanks. 

CY


Thanos Tsakonas於 2014年9月23日星期二UTC+8下午10時06分30秒寫道:

zhou...@gmail.com

unread,
Oct 16, 2014, 2:36:39 AM10/16/14
to taiwa...@googlegroups.com
 HI ,I try the example then
> C5.0.graphviz(treeModel, 'c:\\dtreeout.txt', col.question ='cyan')
Read 52 records
Error: object 'firstindent' not found

I found the code 58 line "
firstindent" is not identified ~
my R version is 3.1.0 and cwhmisc package is 4.0


在 2014年10月9日星期四UTC+8下午3时28分40秒,Wu CY写道:

Wu CY

unread,
Nov 10, 2014, 4:43:47 AM11/10/14
to taiwa...@googlegroups.com
To replace it (firstindent) with "lineindent", then the program will work.The result after replacement is correct I have checked it already. It seems to be a typo.  


zhou...@gmail.com於 2014年10月16日星期四UTC+8下午2時36分39秒寫道:

Thanos Tsakonas

unread,
Nov 10, 2014, 5:23:12 AM11/10/14
to taiwa...@googlegroups.com
You can simply add an initialization (missing) of the following:
 firstindent <- 4
before the main loop starts.
check the updated version on the webpage.

keerthana tina

unread,
Sep 19, 2017, 8:32:19 AM9/19/17
to R軟體使用者論壇

> C5.0.graphviz(treeModel, 'c:\\dtreeout.txt', col.question ='cyan')


\
Hi Thanos, 

When I applied C5.0.graphviz, the error occurred as below.  I just tried the example you showed on http://r-project-thanos.blogspot.tw/2014/09/plot-c50-decision-trees-in-r.html

AM getting an error 

 
 
> C5.0.graphviz(oneTree,
+   'd:\\dtreeout.txt', col.question ='cyan')
Error in C5.0.graphviz(oneTree, "d:\\dtreeout.txt", col.question = "cyan") : 
  could not find function "C5.0.graphviz"


what i should do ???


my code here  !!!!!!!!!!!!!!!!!!!!!!!!!!!!!


library(caret)

Loading required package: lattice

Loading required package: ggplot2

>  inTrain <- createDataPartition(newds$Attrition, p = .75, list = FALSE)

>  training <- newds[ inTrain,]

>  testing <- newds[-inTrain,]

> oneTree <- C5.0(Attrition ~ ., data = training)

>  oneTree

 

Call:

C5.0.formula(formula = Attrition ~ ., data = training)

 

Classification Tree

Number of samples: 1103

Number of predictors: 12

 

Tree size: 37

 

Non-standard options: attempt to group attributes




 
...
Reply all
Reply to author
Forward
0 new messages