# Tree Predictions

### Description

Compute predictions from `party`

objects.

### Usage

1 2 3 4 5 6 7 8 9 10 11 12 13 | ```
## S3 method for class 'party'
predict(object, newdata = NULL, perm = NULL, ...)
predict_party(party, id, newdata = NULL, ...)
## Default S3 method:
predict_party(party, id, newdata = NULL, FUN = NULL, ...)
## S3 method for class 'constparty'
predict_party(party, id, newdata = NULL,
type = c("response", "prob", "quantile", "density", "node"),
at = if (type == "quantile") c(0.1, 0.5, 0.9),
FUN = NULL, simplify = TRUE, ...)
## S3 method for class 'simpleparty'
predict_party(party, id, newdata = NULL,
type = c("response", "prob", "node"), ...)
``` |

### Arguments

`object` |
objects of class |

`newdata` |
an optional data frame in which to look for variables with which to predict, if omitted, the fitted values are used. |

`perm` |
an optional character vector of variable names. Splits of
nodes with a primary split in any of these variables will
be permuted (after dealing with surrogates). Note that
surrogate split in the |

`party` |
objects of class |

`id` |
a vector of terminal node identifiers. |

`type` |
a character string denoting the type of predicted value
returned, ignored when argument |

`FUN` |
a function to extract ( |

`at` |
if the return value is a function (as the empirical cumulative distribution
function or the empirical quantile function), this function is evaluated
at values |

`simplify` |
a logical indicating whether the resulting list of predictions should be converted to a suitable vector or matrix (if possible). |

`...` |
additional arguments. |

### Details

The `predict`

method for `party`

objects
computes the identifiers of the predicted terminal nodes, either
for new data in `newdata`

or for the learning samples
(only possible for objects of class `constparty`

).
These identifiers are delegated to the corresponding
`predict_party`

method which computes (via
`FUN`

for class `constparty`

)
or extracts (class `simpleparty`

) the actual predictions.

### Value

A list of predictions, possibly simplified to a numeric vector, numeric matrix or factor.

### Examples

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 | ```
## fit tree using rpart
library("rpart")
rp <- rpart(skips ~ Opening + Solder + Mask + PadType + Panel,
data = solder, method = 'anova')
## coerce to `constparty'
pr <- as.party(rp)
## mean predictions
predict(pr, newdata = solder[c(3, 541, 640),])
## ecdf
predict(pr, newdata = solder[c(3, 541, 640),], type = "prob")
## terminal node identifiers
predict(pr, newdata = solder[c(3, 541, 640),], type = "node")
## median predictions
predict(pr, newdata = solder[c(3, 541, 640),],
FUN = function(y, w = 1) median(y))
``` |

Want to suggest features or report bugs for rdrr.io? Use the GitHub issue tracker. Vote for new features on Trello.