João Mendes Moreira
2005-Sep-09 13:45 UTC
[R] Finding a decision tree's leaf node from a new value
Dear mailinglist members, I have the following problem: I run a decision tree using the rpart function and, afterwords, I try to find to which leaf node a new register (not used to build the decision tree) belongs to. I will try to explain better: rpart.tree <- rpart(target.value ~., data) leaf.node <- new.function(rpart.tree, new.register) The new register has all the explanatory values used to build the tree but has not the target value. The new.function is the function I am trying to write and shall return the leaf.node from the decision tree where it should belong. What I need ( and I am am not able to) is to reproduce the decision path over my new.register. Thanks in advance Joao Moreira [[alternative HTML version deleted]]
Stephen D. Weigand
2005-Sep-13 04:09 UTC
[R] Finding a decision tree's leaf node from a new value
It sounds to me like you're looking for the function predict.rpart(). Hope this helps, Stephen On Sep 9, 2005, at 8:45 AM, Jo??o Mendes Moreira wrote:> Dear mailinglist members, > > I have the following problem: I run a decision tree using the rpart > function and, afterwords, I try to find to which leaf node a new > register (not used to build the decision tree) belongs to. > > I will try to explain better: > > rpart.tree <- rpart(target.value ~., data) > leaf.node <- new.function(rpart.tree, new.register) > > The new register has all the explanatory values used to build the tree > but has not the target value. > The new.function is the function I am trying to write and shall return > the leaf.node from the decision tree where it should belong. > > What I need ( and I am am not able to) is to reproduce the decision > path over my new.register. > > Thanks in advance > > Joao Moreira