Create prediction of new data with rules in rpart

i want to make prediction of new data in Rpart ,,, from prp documentation i have read. The function maybe should like this

> rpart.predict(survived, newdata=ptitanic[1:3,], rules=TRUE)
died survived
1 0.27253 0.72747 because sex is female
2 0.11111 0.88889 because sex is male & age < 9.5 & sibsp < 3
3 0.27253 0.72747 because sex is female

but rpart.predict not found ,, can everyone tell's me the alternative ?

Here are the functions in the current version of rpart (4.1-13 as of this writing):
https://www.rdocumentation.org/packages/rpart/versions/4.1-13

The documentation for the latest CRAN release will always be at: https://CRAN.R-project.org/package=rpart, or (if you've installed rpart) you can run help(package="rpart") (this works for any package, see documentation re. help functions here).

There is a function rpart.predict(), which is part of a package called rpart.plot:
https://www.rdocumentation.org/packages/rpart.plot/versions/3.0.6

For future reference, it is easier for us to help you if you include a self-contained reproducible example (i.e. a reprex), that way, it's easy to see if the problem is coming from the fact that you don't have the correct libraries loaded.

1 Like

This topic was automatically closed 21 days after the last reply. New replies are no longer allowed.