0
votes

Here, I am predicting the type of glass based on its chemical content.chemical contents are input which are of numeric type(Ri,Na etc) and type of glass is output(Typec) which is factor.After building model using C5.0 I am getting error like

"Error: Tree models only"

This is my code:

train=datax[sample(nrow(datax),80,replace=F),]

test=datax[!(1:nrow(datax))%in%as.numeric(row.names(train)),]

model=C5.0(Typec~.,data=train,rules=T, ntree= 50)

plot(model) 

Here after running the plot instruction Im getting error mentioned.

1
What is the error? Are you sure the model was built successfully? Any errors or warning before the plot() command?AntoniosK
Can you please post a sample of your data? Like dput(datax).RLave
@AntoniosK ya there was no error while building model and there were no warning before plot instruction.And i got 0.83 of accuracy in confusion matrixSree Lakshmi K M
@RLave sure I will.Sree Lakshmi K M
Try to build and plot the model without rules=T. Check more info here: cran.r-project.org/web/packages/C50/vignettes/C5.0.html where it mentions that rules based models have no plot methods.AntoniosK

1 Answers

0
votes
model=C5.0(Typec~.,data=train,rules=T, ntree= 50)

Remove "rules = T" argument and then you'll be able to plot the graph