rpart.predict
From rpart.plot v3.0.8
by Stephen Milborrow
Extended version of predict.rpart
Identical to predict.rpart
but
optionally show the node numbers and rules for the predicted values.
Usage
rpart.predict(object, newdata,
type = c("vector", "prob", "class", "matrix"),
na.action = na.pass,
nn=FALSE, rules=FALSE, ...)
Arguments
- object, newdata, type, na.action
Identical to the same arguments for
predict.rpart
. If bothnn
andrules
areFALSE
, the returned value is identical topredict.rpart
.- nn
If
TRUE
, return adata.frame
with the predictions as usual but with an extra column showing the leaf node number for each prediction.- rules
If
TRUE
, return adata.frame
with the predictions as usual but with an extra column showing the rpart rule (as a string) for each prediction. It may be helpful to useoptions(width=1000)
before printing thisdata.frame
.- ...
Passed on to
rpart.rules
, for exampleclip.facs=TRUE
.
Value
Same as predict.rpart
,
but with additional information if nn=TRUE
and/or rules=TRUE
.
See Also
Examples
# NOT RUN {
data(ptitanic)
model <- rpart(survived ~ ., data = ptitanic, cp = .02)
head(rpart.predict(model, rules=TRUE))
# }
Community examples
Looks like there are no examples yet.