View source: R/methods_e2tree.R
| predict.e2tree | R Documentation |
Predicts classification or regression responses for new data using the fitted E2Tree model.
## S3 method for class 'e2tree'
predict(object, newdata, target = NULL, ...)
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
|
... |
Additional arguments (ignored). |
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).
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)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.