rpart.predict.Rd
Identical to predict.rpart
but
optionally show the node numbers and rules for the predicted values.
rpart.predict(object, newdata, type = c("vector", "prob", "class", "matrix"), na.action = na.pass, nn=FALSE, rules=FALSE, ...)
object, newdata, type, na.action | Identical to the same arguments for |
---|---|
nn | If |
rules | If |
... | Passed on to |
Same as predict.rpart
,
but with additional information if nn=TRUE
and/or rules=TRUE
.
predict.rpart
rpart.rules
data(ptitanic) model <- rpart(survived ~ ., data = ptitanic, cp = .02) head(rpart.predict(model, rules=TRUE))#> died survived #> 1 0.2725322 0.7274678 because sex is female #> 2 0.1111111 0.8888889 because sex is male & age < 9.5 & sibsp < 3 #> 3 0.2725322 0.7274678 because sex is female #> 4 0.8291457 0.1708543 because sex is male & age >= 9.5 #> 5 0.2725322 0.7274678 because sex is female #> 6 0.8291457 0.1708543 because sex is male & age >= 9.5