Dear useRs: Is there a way I could predict the terminal node associated with a new data entry in an rpart environment? In the example below, if I had a new data entry with an AM of 5, I would like to link it to the terminal node 2. My searches led to http://tolstoy.newcastle.edu.au/R/e4/help/08/07/17702.html but I do not seem to be able to operationalize Professor Ripley's suggestions. Many thanks. Tudor> tree.prunen= 2400 node), split, n, loss, yval, (yprob) * denotes terminal node 1) root 2400 779 0 (0.6754167 0.3245833) 2) AM< 6.5 1428 254 0 (0.8221289 0.1778711) * 3) AM>=6.5 972 447 1 (0.4598765 0.5401235) 6) P>=10.39666 390 86 0 (0.7794872 0.2205128) * 7) P< 10.39666 582 143 1 (0.2457045 0.7542955) * -- View this message in context: http://r.789695.n4.nabble.com/rpart-predict-terminal-nodes-for-new-observations-tp4630104.html Sent from the R help mailing list archive at Nabble.com.
On 15.05.2012 16:30, tudor wrote:> Dear useRs: > > Is there a way I could predict the terminal node associated with a new data > entry in an rpart environment? In the example below, if I had a new data > entry with an AM of 5, I would like to link it to the terminal node 2. My > searches led to http://tolstoy.newcastle.edu.au/R/e4/help/08/07/17702.html > but I do not seem to be able to operationalize Professor Ripley's > suggestions.Use the predict() function. Uwe Ligges> Many thanks. > > Tudor > >> tree.prune > n= 2400 > > node), split, n, loss, yval, (yprob) > * denotes terminal node > > 1) root 2400 779 0 (0.6754167 0.3245833) > 2) AM< 6.5 1428 254 0 (0.8221289 0.1778711) * > 3) AM>=6.5 972 447 1 (0.4598765 0.5401235) > 6) P>=10.39666 390 86 0 (0.7794872 0.2205128) * > 7) P< 10.39666 582 143 1 (0.2457045 0.7542955) * > > > -- > View this message in context: http://r.789695.n4.nabble.com/rpart-predict-terminal-nodes-for-new-observations-tp4630104.html > Sent from the R help mailing list archive at Nabble.com. > > ______________________________________________ > R-help at r-project.org mailing list > https://stat.ethz.ch/mailman/listinfo/r-help > PLEASE do read the posting guide http://www.R-project.org/posting-guide.html > and provide commented, minimal, self-contained, reproducible code.
Hi Uwe: Thanks a lot for your reply. I contemplated the use of the predict() function but realized that it could not return what I needed (i.e., the terminal nodes and not the classes). I went back to the post of Professor Ripley (http://tolstoy.newcastle.edu.au/R/e4/help/08/07/17702.html) and did find a way to get the terminal nodes. I am showing this approach below in case other useRs face a similar problem. Many thanks. Tudor nodes <- rpart:::pred.rpart(tree.prune,rpart:::rpart.matrix(es)) where tree.prune is the rpart object and es is the estimation data set. -- View this message in context: http://r.789695.n4.nabble.com/rpart-predict-terminal-nodes-for-new-observations-tp4630104p4630508.html Sent from the R help mailing list archive at Nabble.com.
Possibly Parallel Threads
- VMX status report. Xen: #17702 & Xen0: #559 -- no new issue
- The security id structure is invalid
- Improper directory removal causes file system havoc (PR#11738)
- Improper directory removal causes file system havoc (PR#11747)
- Asterisk 16.6.1: PJSIP: delayed action of core since update to 16.6.1