online.ODRF {ODRF} | R Documentation |
using new training data to update an existing ODRF
.
Description
Update existing ODRF
using new data to improve the model.
Usage
## S3 method for class 'ODRF'
online(obj, X, y, weights = NULL, MaxDepth = Inf, ...)
Arguments
obj |
An object of class |
X |
An new n by d numeric matrix (preferable) or data frame used to update the object of class |
y |
A new response vector of length n used to update the object of class |
weights |
A vector of non-negative observational weights; fractional weights are allowed (default NULL). |
MaxDepth |
The maximum depth of the tree (default |
... |
Optional parameters to be passed to the low level function. |
Value
The same result as ODRF
.
See Also
Examples
# 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, ])
index <- seq(floor(nrow(train_data) / 2))
forest <- ODRF(varieties_of_wheat ~ ., train_data[index, ],
split = "gini", parallel = FALSE, ntrees = 50
)
online_forest <- online(forest, train_data[-index, -8], train_data[-index, 8])
pred <- predict(online_forest, test_data[, -8])
# 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, ])
index <- seq(floor(nrow(train_data) / 2))
forest <- ODRF(Density ~ ., train_data[index, ],
split = "mse", parallel = FALSE
)
online_forest <- online(
forest, train_data[-index, -1],
train_data[-index, 1]
)
pred <- predict(online_forest, test_data[, -1])
# estimation error
mean((pred - test_data[, 1])^2)
[Package ODRF version 0.0.4 Index]