Prediction of test data using a fitted Treee object
# S3 method for Treee
predict(object, newdata, type = c("response", "prob", "all", "grove"), ...)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.
a fitted model object of class Treee, which is assumed to be
the result of the Treee() function.
data frame containing the values at which predictions are required. Missing values are allowed.
character string denoting the type of predicted value returned.
The default is to return the predicted class (type = 'response'). The
predicted posterior probabilities for each class will be returned if type = 'prob'. 'all' returns a data frame with predicted classes, posterior
probabilities, and the predicted node indices. If cross-validation is
carried out during the LDATree fitting, 'grove' option is available and
will output an ensemble result from k LDATrees where k is the number of
cross-validation.
further arguments passed to or from other methods.
fit <- Treee(Species~., data = iris)
predict(fit,iris)
# output prosterior probabilities
predict(fit,iris,type = "prob")
Run the code above in your browser using DataLab