3 #' Forecaster (abstract class, implemented by all forecasters)
5 #' @field params List of computed parameters, for post-run analysis (dev)
6 #' @field data Dataset, object of class Data
7 #' @field pjump Function: how to predict the jump at day interface ?
10 #' @importFrom R6 R6Class
11 Forecaster = R6::R6Class("Forecaster",
18 initialize = function(data, pjump)
19 initialize(self, private, data, pjump)
21 predictSerie = function(today, memory, horizon, ...)
22 predictSerie(private, today, memory, horizon, ...)
24 predictShape = function(today, memory, horizon, ...)
25 predictShape(private, today, memory, horizon, ...)
27 getParameters = function()
28 getParameters(private)
32 #' Initialize (generic) Forecaster object
34 #' @param o Object of class Forecaster
35 #' @param private List of private members in o
36 #' @param data Object of class Data
37 #' @param pjump Function to predict jump
38 initialize = function(o, private, data, pjump)
46 #' Obtain a new forecasted time-serie
48 #' @inheritParams initialize
49 #' @param today Index for current prediction
50 #' @param memory Depth in data (in days)
51 #' @param horizon Number of hours to forecast
52 predictSerie = function(private, today, memory, horizon, ...)
54 # Parameters (potentially) computed during shape prediction stage
55 predicted_shape = predictShape(today, memory, horizon, ...)
56 predicted_delta = private$.pjump(private$.data, today, memory, horizon, params, ...)
57 # Predicted shape is aligned it on the end of current day + jump
58 predicted_shape + tail(private$.data$getSerie(today),1) - predicted_shape[1] + predicted_delta
61 #' Shape prediction (centered curve)
63 #' @inheritParams predictSerie
64 predictShape = function(private, today, memory, horizon, ...)
65 #empty default implementation: to implement in inherited classes
67 #' Get parameters list
69 #' @inheritParams initialize
70 getParameters = function(private)