-#' @include ShapeForecaster.R
+#' @include Forecaster.R
#'
-#' @title Neighbors Shape Forecaster
+#' @title Neighbors Forecaster
#'
#' @description Predict tomorrow as a weighted combination of "futures of the past" days.
-#' Inherits \code{\link{ShapeForecaster}}
-NeighborsShapeForecaster = setRefClass(
- Class = "NeighborsShapeForecaster",
- contains = "ShapeForecaster",
+#' Inherits \code{\link{Forecaster}}
+NeighborsForecaster = setRefClass(
+ Class = "NeighborsForecaster",
+ contains = "Forecaster",
methods = list(
initialize = function(...)
{
callSuper(...)
},
- predict = function(today, memory, horizon, ...)
+ predictShape = function(today, memory, horizon, ...)
{
# (re)initialize computed parameters
params <<- list("weights"=NA, "indices"=NA, "window"=NA)
mix_strategy = ifelse(hasArg("mix_strategy"), list(...)$mix_strategy, "neighb") #or "mult"
same_season = ifelse(hasArg("same_season"), list(...)$same_season, TRUE)
if (hasArg(h_window))
- return (.predictAux(fdays_indices, today, horizon, list(...)$h_window, kernel, simtype,
- simthresh, mix_strategy, FALSE))
+ return (.predictShapeAux(fdays_indices, today, horizon, list(...)$h_window, kernel,
+ simtype, simthresh, mix_strategy, FALSE))
#END GET
# Indices for cross-validation; TODO: 45 = magic number
{
nb_jours = nb_jours + 1
# mix_strategy is never used here (simtype != "mix"), therefore left blank
- prediction = .predictAux(fdays_indices, i, horizon, h, kernel, simtype, simthresh,
- "", FALSE)
+ prediction = .predictShapeAux(fdays_indices, i, horizon, h, kernel, simtype,
+ simthresh, "", FALSE)
if (!is.na(prediction[1]))
error = error + mean((data$getCenteredSerie(i+1)[1:horizon] - prediction)^2)
}
if (simtype == "endo")
{
- return (.predictAux(fdays_indices, today, horizon, h_best_endo, kernel, "endo",
+ return (.predictShapeAux(fdays_indices, today, horizon, h_best_endo, kernel, "endo",
simthresh, "", TRUE))
}
if (simtype == "exo")
{
- return (.predictAux(fdays_indices, today, horizon, h_best_exo, kernel, "exo",
+ return (.predictShapeAux(fdays_indices, today, horizon, h_best_exo, kernel, "exo",
simthresh, "", TRUE))
}
if (simtype == "mix")
{
- return (.predictAux(fdays_indices, today, horizon, c(h_best_endo,h_best_exo), kernel,
- "mix", simthresh, mix_strategy, TRUE))
+ return (.predictShapeAux(fdays_indices, today, horizon, c(h_best_endo,h_best_exo),
+ kernel, "mix", simthresh, mix_strategy, TRUE))
}
},
# Precondition: "today" is full (no NAs)
- .predictAux = function(fdays_indices, today, horizon, h, kernel, simtype, simthresh,
+ .predictShapeAux = function(fdays_indices, today, horizon, h, kernel, simtype, simthresh,
mix_strategy, final_call)
{
dat = data$data #HACK: faster this way...