predict.Treee {LDATree} | R Documentation |
Predictions from a fitted Treee object
Description
Prediction of test data using a fitted Treee object
Usage
## S3 method for class 'Treee'
predict(object, newdata, type = c("response", "prob", "all", "grove"), ...)
Arguments
object |
a fitted model object of class |
newdata |
data frame containing the values at which predictions are required. Missing values are allowed. |
type |
character string denoting the type of predicted value returned.
The default is to return the predicted class ( |
... |
further arguments passed to or from other methods. |
Value
The function returns different values based on the type
, if
-
type = 'response'
: vector of predicted responses. -
type = 'prob'
: a data frame of the posterior probabilities. Each class takes a column. -
type = 'all'
: a data frame contains the predicted responses, posterior probabilities, and the predicted node indices. -
type = 'grove'
: vector of predicted responses using the ensemble method. Only available when cross-validation is carried out during the tree generating process.
Note: for factor predictors, if it contains a level which is not used to
grow the tree, it will be converted to missing and will be imputed according
to the missingMethod
in the fitted tree.
Examples
fit <- Treee(Species~., data = iris)
predict(fit,iris)
# output prosterior probabilities
predict(fit,iris,type = "prob")