% Generated by roxygen2: do not edit by hand
% Please edit documentation in R/methods_e2tree.R
\name{predict.e2tree}
\alias{predict.e2tree}
\title{Predict Responses from an E2Tree Model}
\usage{
\method{predict}{e2tree}(object, newdata, target = NULL, ...)
}
\arguments{
\item{object}{An e2tree object.}

\item{newdata}{A data frame containing the new observations. If missing,
the fitted values for the training data are returned.}

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

\item{...}{Additional arguments (ignored).}
}
\value{
For regression: a data frame with columns \code{fit} (predicted
value) and \code{sd} (standard deviation of the response within the
terminal node, computed from the training data).
For classification: a data frame with columns \code{fit} (predicted class),
\code{accuracy} (probability of the predicted class), and \code{score}
(probability of the target class).
}
\description{
Predicts classification or regression responses for new data using the
fitted E2Tree model.
}
\examples{
\donttest{
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)
}

}
