Get decision tree rule/path pattern for every row of predicted dataset for rpart/ctree package in R
I have built a decision tree model in R using rpart and ctree . I also have predicted a new dataset using the built model and got predicted probabilities and classes. However, I would like to extract the rule/path, in a single string, for every observation (in predicted dataset) has followed. Storing this data in tabular format, I can explain prediction with reason in a automated manner without opening R. Which means I want to got following. ObsID Probability PredictedClass PathFollowed 1 0.68 Safe CarAge < 10 & Country = Germany & Type = Compact & Price < 12822.5 2 0.76 Safe CarAge < 10 &