3

I created a decision tree in rattle for the in-built wine dataset.
The output is shown below

Summary of the Decision Tree model for Classification (built using 'rpart'):

library(rpart)
library(rattle)

n= 124 

node), split, n, loss, yval, (yprob)
      * denotes terminal node

 1) root 124 73 2 (0.30645161 0.41129032 0.28225806)  
   2) Proline>=953.5 33  0 1 (1.00000000 0.00000000 0.00000000) *
   3) Proline< 953.5 91 40 2 (0.05494505 0.56043956 0.38461538)  
     6) Intensity< 3.825 44  0 2 (0.00000000 1.00000000 0.00000000) *
     7) Intensity>=3.825 47 12 3 (0.10638298 0.14893617 0.74468085)  
      14) Flavanoids>=1.385 13  6 2 (0.38461538 0.53846154 0.07692308) *
      15) Flavanoids< 1.385 34  0 3 (0.00000000 0.00000000 1.00000000) *

Classification tree:
rpart(formula = Class ~ ., data = crs$dataset[crs$train, c(crs$input, 
    crs$target)], method = "class", parms = list(split = "information"), 
    control = rpart.control(usesurrogate = 0, maxsurrogate = 0))

Variables actually used in tree construction:
[1] Flavanoids Intensity  Proline   

Root node error: 73/124 = 0.58871

n= 124 

        CP nsplit rel error  xerror     xstd
1 0.452055      0  1.000000 1.00000 0.075061
2 0.383562      1  0.547945 0.52055 0.070325
3 0.082192      2  0.164384 0.26027 0.054946
4 0.010000      3  0.082192 0.21918 0.051137

Time taken: 0.02 secs

The rules are listed below

Tree as rules: 

 Rule number: 2 [Class=1 cover=33 (27%) prob=1.00]
   Proline>=953.5

 Rule number: 14 [Class=2 cover=13 (10%) prob=0.38]
   Proline< 953.5
   Intensity>=3.825
   Flavanoids>=1.385

 Rule number: 15 [Class=3 cover=34 (27%) prob=0.00]
   Proline< 953.5
   Intensity>=3.825
   Flavanoids< 1.385

 Rule number: 6 [Class=2 cover=44 (35%) prob=0.00]
   Proline< 953.5
   Intensity< 3.825

[1] 2 6 1 5 3 7 4

The output plot which I got is shown below

The output of the tree plot

When I try to plot the tree, it is showing only the outline of the nodes. Nothing else is listed.
I tried with different datasets. All are showing the same result.
All plots other than decision tree are working perfectly fine.

How to resolve this? Is this related to any package problem?

dvs
  • 491
  • 1
  • 8
  • 26
  • I do not understand your rpart code as it seems to not show the wine data as input but a different dataset. Could you also show the code you used in rattle to show the decision tree, I guess you used fancyRpartPlot? – Ruthger Righart May 29 '15 at 07:35
  • You said that you used actually "Flavanoids Intensity Proline" in your tree construction. In the wine dataset there is not a variable called Intensity. – Ruthger Righart May 29 '15 at 07:43

2 Answers2

4

Resolved It..
Removed the following packages and reinstalled

   remove.packages('rpart.plot')
   remove.packages('rpart')
   remove.packages('rattle')
   remove.packages('RColorBrewer')

Install them again from console (then it will install all the dependencies)

install.packages('rattle')
install.packages('rpart')
install.packages('rpart.plot')
install.packages('RColorBrewer')

Now reload the packages and it resolved the problem

library(rattle)
library(rpart.plot)
library(RColorBrewer)
dvs
  • 491
  • 1
  • 8
  • 26
1
library(rpart)
library(rattle)

I do not have sufficient information to answer your question and so I am not sure what is going wrong in your case. But please find below an example code to produce a tree using fancyRpartPlot.

model<-rpart(Type~ Flavanoids+Proline+Hue, data=wine)
fancyRpartPlot(model)

enter image description here

Ruthger Righart
  • 4,218
  • 2
  • 24
  • 32