Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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.

like image 287
Mostafa790 Avatar asked Nov 01 '22 00:11

Mostafa790


1 Answers

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.

like image 103
Atendra Avatar answered Nov 13 '22 16:11

Atendra