Extracting regression tree models built with R rpart
-
07-07-2021 - |
Question
I've built several regression tree models using the rpart
package in R and I need to migrate them into another language such as Perl.
The predict function works fine within R, but is there a way to print out something like the weighted formula at each node?
Solution
I believe what you are trying to do can be done using a little hack of the Rattle package/GUI. If you install Rattle then from the command line use the asRules()
function on your rpart fit object and you will get back a human readable rules set. I have used these rules to quickly convert to SQL or other languages in seconds. I hope this helps.
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow