predict.ODRF | R Documentation |
Prediction of ODRF for an input matrix or data frame.
## S3 method for class 'ODRF'
predict(object, Xnew, type = "response", weight.tree = FALSE, ...)
object |
An object of class ODRF, the same created by the function |
Xnew |
An n by d numeric matrix (preferable) or data frame. The rows correspond to observations and columns correspond to features. Note that if there are NA values in the data 'Xnew', which will be replaced with the average value. |
type |
One of |
weight.tree |
Whether to weight the tree, if |
... |
Arguments to be passed to methods. |
A set of vectors in the following list:
response
: the predicted values of the new data.
prob
: matrix of class probabilities (one column for each class and one row for each input). If object$split
is mse
, a vector of tree weights is returned.
tree
: It is a matrix where each column is a prediction for each tree.
Zhan, H., Liu, Y., & Xia, Y. (2022). Consistency of The Oblique Decision Tree and Its Random Forest. arXiv preprint arXiv:2211.12653.
ODRF
predict.ODT
# Classification with Oblique Decision Random Forest
data(seeds)
set.seed(221212)
train <- sample(1:209, 80)
train_data <- data.frame(seeds[train, ])
test_data <- data.frame(seeds[-train, ])
forest <- ODRF(varieties_of_wheat ~ ., train_data,
split = "entropy", parallel = FALSE,ntrees = 50
)
pred <- predict(forest, test_data[, -8], weight.tree = TRUE)
# classification error
(mean(pred != test_data[, 8]))
# Regression with Oblique Decision Random Forest
data(body_fat)
set.seed(221212)
train <- sample(1:252, 80)
train_data <- data.frame(body_fat[train, ])
test_data <- data.frame(body_fat[-train, ])
forest <- ODRF(Density ~ ., train_data, split = "mse", parallel = FALSE,
ntrees = 50, TreeRandRotate=TRUE)
pred <- predict(forest, test_data[, -1])
# estimation error
mean((pred - test_data[, 1])^2)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.