Skip to contents

Update existing ODT using new data to improve the model.

Usage

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

Arguments

obj

an object of class ODT.

X

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

y

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

weights

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 ODT.

Examples

# Classification with Oblique Decision Tree
data(seeds)
set.seed(221212)
train <- sample(1:209, 100)
train_data <- data.frame(seeds[train, ])
test_data <- data.frame(seeds[-train, ])
index <- seq(floor(nrow(train_data) / 2))
tree <- ODT(varieties_of_wheat ~ ., train_data[index, ], split = "gini")
online_tree <- online(tree, train_data[-index, -8], train_data[-index, 8])
pred <- predict(online_tree, test_data[, -8])
# classification error
(mean(pred != test_data[, 8]))
#> [1] 0.1009174

# Regression with Oblique Decision Tree
data(body_fat)
set.seed(221212)
train <- sample(1:252, 100)
train_data <- data.frame(body_fat[train, ])
test_data <- data.frame(body_fat[-train, ])
index <- seq(floor(nrow(train_data) / 2))
tree <- ODT(Density ~ ., train_data[index, ], split = "mse")
online_tree <- online(tree, train_data[-index, -1], train_data[-index, 1])
pred <- predict(online_tree, test_data[, -1])
# estimation error
mean((pred - test_data[, 1])^2)
#> [1] 6.186264e-05