predict.Treee {LDATree}R Documentation

Predictions From a Fitted Treee Object

Description

Generate predictions on new data using a fitted Treee model.

Usage

## S3 method for class 'Treee'
predict(object, newdata, type = c("response", "prob", "all"), ...)

Arguments

object

A fitted model object of class Treee, typically the result of the Treee() function.

newdata

A data frame containing the predictor variables. Missing values are allowed and will be handled according to the fitted tree's method for handling missing data.

type

A character string specifying the type of prediction to return. Options are:

  • 'response': returns the predicted class for each observation (default).

  • 'prob': returns a data frame of posterior probabilities for each class.

  • 'all': returns a data frame containing predicted classes, posterior probabilities, and the predicted node indices.

...

Additional arguments passed to or from other methods.

Value

Depending on the value of type, the function returns:

Note: For factor predictors, if a level not present in the training data is found in newdata, it will be treated as missing and handled according to the missingMethod specified in the fitted tree.

Examples

fit <- Treee(datX = iris[, -5], response = iris[, 5], verbose = FALSE)
head(predict(fit, iris)) # Predicted classes
head(predict(fit, iris[, -5], type = "prob")) # Posterior probabilities
head(predict(fit, iris[, -5], type = "all")) # Full details

[Package LDATree version 0.2.0 Index]