predict.e2tree: Predict Responses from an E2Tree Model

View source: R/methods_e2tree.R

predict.e2treeR Documentation

Predict Responses from an E2Tree Model

Description

Predicts classification or regression responses for new data using the fitted E2Tree model.

Usage

## S3 method for class 'e2tree'
predict(object, newdata, target = NULL, ...)

Arguments

object

An e2tree object.

newdata

A data frame containing the new observations. If missing, the fitted values for the training data are returned.

target

Character string specifying the target class for computing classification scores. Only used for classification trees. Default is NULL, which uses the first level.

...

Additional arguments (ignored).

Value

For regression: a data frame with columns fit (predicted value) and sd (standard deviation of the response within the terminal node, computed from the training data). For classification: a data frame with columns fit (predicted class), accuracy (probability of the predicted class), and score (probability of the target class).

Examples


data(iris)
smp_size <- floor(0.75 * nrow(iris))
train_ind <- sample(seq_len(nrow(iris)), size = smp_size)
training <- iris[train_ind, ]
validation <- iris[-train_ind, ]

ensemble <- randomForest::randomForest(Species ~ ., data = training,
  importance = TRUE, proximity = TRUE)
D <- createDisMatrix(ensemble, data = training, label = "Species",
  parallel = list(active = FALSE, no_cores = 1))
setting <- list(impTotal = 0.1, maxDec = 0.01, n = 2, level = 5)
tree <- e2tree(Species ~ ., training, D, ensemble, setting)

## Predict on new data
pred <- predict(tree, newdata = validation)



e2tree documentation built on May 15, 2026, 5:06 p.m.