John
John

Reputation: 356

Can I make a diagram out of R Cubist outcome?

I just started using the R package Cubist which creates output like this:

Cubist [Release 2.07 GPL Edition] Tue Jul 09 19:46:48 2013

Target attribute `outcome'

Read 260 cases (9 attributes) from undefined.data

Model:

Rule 1: [26 cases, mean 0.3, range 0 to 8, est err 0.3]

if
    B4 <= 54.96766
    B7 > 39.66716
then
    outcome = 0

Rule 2: [48 cases, mean 0.3, range 0 to 8, est err 0.6]

if
    B1 > 56.99043
    B5 > 74.11118
    B6 > 155.996
then
    outcome = 9.1 - 0.17 B5 + 0.25 B7 + 0.15 NDVI

I can make use of the model using predict, but I would like to make a graphic of the tree. I don't see that it is possible looking at the manual, but I want to know if anyone knows of a way to do this.

Upvotes: 0

Views: 912

Answers (2)

jprockbelly
jprockbelly

Reputation: 1607

rpart and partykit are both useful R packages for plotting tree style diagrams.

edit: see example of partykit here here

Upvotes: 0

agstudy
agstudy

Reputation: 121588

You can use dotplot.cubist to get a visual view of the model conditions and coefficients. Here an example:

library(mlbench)
library(Cubist)
library(gridExtra)
data(BostonHousing)
mod1 <- cubist(x = BostonHousing[, -14], y = BostonHousing$medv)
summary(mod1)
p1 <- dotplot(mod1, what = "splits",main='Conditions')
p2 <- dotplot(mod1, what = "coefs",main='Coefs')
grid.arrange(p1,p2)

enter image description here

Upvotes: 1

Related Questions