as.rpart: Convert an E2Tree Object to rpart Format

View source: R/coercion.R

as.rpartR Documentation

Convert an E2Tree Object to rpart Format

Description

Coerces an e2tree object into an rpart object, which can then be used with standard rpart methods for printing, plotting (e.g., via rpart.plot), and prediction.

Usage

as.rpart(x, ...)

## S3 method for class 'e2tree'
as.rpart(x, ensemble, ...)

Arguments

x

An e2tree object.

...

Additional arguments (ignored).

ensemble

The ensemble model used to build the E2Tree. Supported classes: randomForest, ranger, xgb.Booster, lgb.Booster, gbm, catboost.CatBoost.

Value

An rpart object.

See Also

as.party.e2tree for conversion to partykit format.

Examples


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)



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