5
\alias{predict_party.default}
6
\alias{predict_party.constparty}
7
\alias{predict_party.simpleparty}
8
\title{ Tree Predictions }
11
Compute predictions from \code{party} objects.
15
\method{predict}{party}(object, newdata = NULL, ...)
16
predict_party(party, id, newdata = NULL, ...)
17
\method{predict_party}{default}(party, id, newdata = NULL, ...)
18
\method{predict_party}{constparty}(party, id, newdata = NULL,
19
type = c("response", "prob", "node"), FUN = NULL,
21
\method{predict_party}{simpleparty}(party, id, newdata = NULL,
22
type = c("response", "prob", "node"), ...)
25
\item{object}{ objects of class \code{\link{party}}. }
26
\item{newdata}{ an optional data frame in which to look for variables with
27
which to predict, if omitted, the fitted values are used.}
28
\item{party}{ objects of class \code{\link{party}}. }
29
\item{id}{ a vector of terminal node identifiers. }
30
\item{type}{ a character string denoting the type of predicted value
31
returned, ignored when argument \code{FUN} is given.
32
For \code{"response"}, the mean of a numeric response, the predicted
33
class for a categorical response or the median survival time
34
for a censored response is returned. For a categorical response,
35
\code{"prob"} returns the matrix of conditional class probabilities
36
(\code{simplify = TRUE}) or a list with the conditional
37
class probabilities for each observation (\code{simplify = FALSE}).
38
\code{"node"} returns an integer vector of terminal node
40
\item{FUN}{ a function to compute summary statistics, i.e., constant
41
predictions for each node with argument list \code{(y, w)}
42
where \code{y} is the response and \code{w} are case weights.}
43
\item{simplify}{ a logical indicating whether the resulting list
44
of predictions should be converted to a suitable
45
vector or matrix (if possible).}
46
\item{\dots}{ additional arguments. }
50
The \code{\link{predict}} method for \code{\link{party}} objects
51
computes the identifiers of the predicted terminal nodes, either
52
for new data in \code{newdata} or for the learning samples
53
(only possible for objects of class \code{constparty}).
54
These identifiers are delegated to the corresponding
55
\code{predict_party} method which computes (via
56
\code{FUN} for class \code{constparty})
57
or extracts (class \code{simpleparty}) the actual predictions.
61
A list of predictions, possibly simplified to a numeric vector,
62
numeric matrix or factor.
66
## fit tree using rpart
68
rp <- rpart(skips ~ Opening + Solder + Mask + PadType + Panel,
69
data = solder, method = 'anova')
71
## coerce to `constparty'
75
predict(pr, newdata = solder[c(3, 541, 640),])
77
## terminal node identifiers
78
predict(pr, newdata = solder[c(3, 541, 640),], type = "node")
81
predict(pr, newdata = solder[c(3, 541, 640),],
82
FUN = function(y, w = 1) median(y))