update_weights {tsensembler} | R Documentation |
Updating the weights of base models
Description
Update the weights of base models of a ADE-class
or DETS-class
ensemble.
This is accomplished by using computing the loss of the base models
in new recent observations.
Usage
update_weights(object, newdata)
## S4 method for signature 'ADE'
update_weights(object, newdata)
## S4 method for signature 'DETS'
update_weights(object, newdata)
Arguments
object |
a |
newdata |
new data used to update the most recent observations of the time series. At prediction time these observations are used to compute the weights of the base models |
Note
Updating the weights of an ensemble is only necessary between
different calls of the functions predict
or forecast
.
Otherwise, if consecutive know observations are predicted
(e.g. a validation/test set) the updating is automatically done internally.
See Also
update_weights
for the weight updating method
for an ADE
model, and update_weights
for the same method
for a DETS
model
Other updating models:
update_ade_meta()
,
update_ade()
Examples
data("water_consumption")
dataset <- embed_timeseries(water_consumption, 5)
# toy size for checks
train <- dataset[1:300,]
test <- dataset[301:305, ]
specs <- model_specs(c("bm_ppr","bm_glm","bm_mars"), NULL)
## same with model <- DETS(target ~., train, specs)
model <- ADE(target ~., train, specs)
# if consecutive know observations are predicted (e.g. a validation/test set)
# the updating is automatically done internally.
predictions1 <- predict(model, test)@y_hat
# otherwise, the models need to be updated
predictions <- numeric(nrow(test))
# predict new data and update the weights of the model
for (i in seq_along(predictions)) {
predictions[i] <- predict(model, test[i, ])@y_hat
model <- update_weights(model, test[i, ])
}
#all.equal(predictions1, predictions)