% Generated by roxygen2: do not edit by hand
% Please edit documentation in R/coercion.R
\name{as.rpart}
\alias{as.rpart}
\alias{as.rpart.e2tree}
\title{Convert an E2Tree Object to rpart Format}
\usage{
as.rpart(x, ...)

\method{as.rpart}{e2tree}(x, ensemble, ...)
}
\arguments{
\item{x}{An e2tree object.}

\item{...}{Additional arguments (ignored).}

\item{ensemble}{The ensemble model used to build the E2Tree. Supported classes:
\code{randomForest}, \code{ranger}, \code{xgb.Booster}, \code{lgb.Booster},
\code{gbm}, \code{catboost.CatBoost}.}
}
\value{
An \code{rpart} object.
}
\description{
Coerces an \code{e2tree} object into an \code{rpart} object, which can
then be used with standard rpart methods for printing, plotting
(e.g., via \code{rpart.plot}), and prediction.
}
\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, ]

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)

rpart_obj <- as.rpart(tree, ensemble)
}

}
\seealso{
\code{\link{as.party.e2tree}} for conversion to partykit format.
}
