Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to handle continuous and discrete variables in 'rpart' - decision trees using R?

I am creating some decision trees using the package rpart in R. I have discrete variables like age, no.of.children in my dataset. But the resulting decision tree has these variables n decimals. Which means, it is considered as continuous variables.

How to avoid this and how can i get these variables as discrete in my decision tree?

like image 824
Manoj G Avatar asked Feb 03 '26 12:02

Manoj G


1 Answers

Make them into factors, the standard way to represent discrete variables in R.

like image 156
IRTFM Avatar answered Feb 05 '26 04:02

IRTFM



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!