Mostafa90
Mostafa90

Reputation: 1706

Decision tree completely different between rpart and party package

I want to compare CART and CHAID algorithm, I choose rpart (cart algorithm) and party (chaid algorithm) to see the difference between them. My data is about blood pressure : enter image description here

The party function returns me :

library(party)
# par <- ctree_control(minsplit=20, minbucket=10)
arbre <- ctree(bpress_level ~ ., data = df)
arbre
plot(arbre)

enter image description here

The rpart package returns me :

library(rpart)
fit <- rpart(bpress_level ~ .,
             method="class", data=df)

printcp(fit) # display the results
plotcp(fit)

plot(fit, uniform=TRUE,
     main="Classification Tree for pressure level")
text(fit, use.n=TRUE, all=TRUE, cex=.8)

enter image description here

I don't inderstand why the tree decisin are so different, is it normal ? Why for party package the algorithm ignores like smoke, stress, gender .... Thank you in advance.

Upvotes: 5

Views: 11099

Answers (1)

Atendra Gautam
Atendra Gautam

Reputation: 475

First of all ctree ([party]) doesn't uses CHAID algorithm. It is very much similar to CHAID but not CHAID. CHAID can only be applied when data is categorical in nature.

Of course, there are numerous other recursive partitioning algorithms that are more or less similar to CHAID which can deal with mixed data types. For example, the CTree algorithm (conditional inference trees) is also based on significance tests and is available in ctree() in package partykit.

Upvotes: 2

Related Questions