Skip to contents

Update existing ODRF using new data to improve the model.

Usage

# S3 method for ODRF
online(obj, X, y, weights = NULL, MaxDepth = Inf, ...)

Arguments

obj

An object of class ODRF.

X

An new n by d numeric matrix (preferable) or data frame used to update the object of class ODRF.

y

A new response vector of length n used to update the object of class ODRF.

weights

A vector of non-negative observational weights; fractional weights are allowed (default NULL).

MaxDepth

The maximum depth of the tree (default Inf).

...

Optional parameters to be passed to the low level function.

Value

The same result as ODRF.

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]))
#> [1] 0.03875969

# Regression with Oblique Decision Random Forest
# \donttest{
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)
#> [1] 4.503374e-05
# }