rpart icon indicating copy to clipboard operation
rpart copied to clipboard

Decision Tree leaf node assignments in rpart

Open wreck84 opened this issue 2 years ago • 1 comments

I want to create a feature/column in a dataset that indicates which leaf node a record belongs to, based on the leaf node prediction. Examining the feature values and conducting a one-way anova on the leaf nodes are the main goals.

I do not understand the rpart documentation enough to see if rpart already provides that functionality. I am self-taught in R.

I tried to create a nested series of ifelse statements one at a time to make sure I didn't flub up on the syntax, but that only worked for a while. Eventually, it got to the point where I got error messages that could not be resolved. It is a very large decision tree with 16 leaf nodes.

Performing this task in R would be best, but exporting the dataset to Excel and re-importing it into R seems to be my only alternative at the moment.

I would appreciate it if someone had any suggestions on how to complete this task in R, rpart, or some other package.

wreck84 avatar Feb 06 '23 18:02 wreck84

You can use the rpart.predict.leaves() function from the treeClust package. See the documentation here.

RoelVerbelen avatar Mar 15 '23 05:03 RoelVerbelen