From: Benjamin Auder Date: Fri, 7 Apr 2017 10:01:01 +0000 (+0200) Subject: clarify data acquisition; TODO: improve doc + usage X-Git-Url: https://git.auder.net/doc/html/css/current/git-logo.png?a=commitdiff_plain;h=4f5204f064d37ba0ec2988ba16a7011d7f0a45cd;p=talweg.git clarify data acquisition; TODO: improve doc + usage --- diff --git a/pkg/R/Data.R b/pkg/R/Data.R index 610c0c4..39f3837 100644 --- a/pkg/R/Data.R +++ b/pkg/R/Data.R @@ -57,18 +57,16 @@ Data = R6::R6Class("Data", getStdHorizon = function() 24 - as.POSIXlt( private$.data[[1]]$time[1] )$hour + 1 , - append = function(time, exo_hat) - private$.data[[length(private$.data)+1]] <- list("time"=time,"exo_hat"=exo_hat) - , - append = function(time, serie, exo) + append = function(time, serie, exo, exo_hat) { - index <- length(private$.data) level = mean(serie, na.rm=TRUE) centered_serie = serie - level - private$.data[[index]]$time <- time - private$.data[[index]]$centered_serie <- centered_serie - private$.data[[index]]$level <- level - private$.data[[index]]$exo <- exo + private$.data[[length(private$.data)+1]] <- list( + "time"=time, #H-24 --> H-1 + "centered_serie"=centered_serie, #at 'time' + "level"=level, #at 'time' + "exo"=exo, #at 'time' (yersteday 0am to last midnight) + "exo_hat"=exo_hat) #today 0am to next midnight }, getTime = function(index) { diff --git a/pkg/R/computeForecast.R b/pkg/R/computeForecast.R index 53dbc14..4bab811 100644 --- a/pkg/R/computeForecast.R +++ b/pkg/R/computeForecast.R @@ -34,8 +34,6 @@ #' memory=500, horizon=12, ncores=1) #' \dontrun{#Sketch for real-time mode: #' data <- Data$new() -#' # Initialize: first day has no predictions attached -#' data$initialize() #' forecaster <- MyForecaster$new(myJumpPredictFunc) #' repeat { #' # In the morning 7am+ or afternoon 1pm+: diff --git a/pkg/R/getData.R b/pkg/R/getData.R index 4e2e3fd..268c54a 100644 --- a/pkg/R/getData.R +++ b/pkg/R/getData.R @@ -86,7 +86,11 @@ getData = function(ts_data, exo_data, input_tz="GMT", date_format="%d/%m/%Y %H:% } exo = as.data.frame( exo_df[i,2:(1+nb_exos)] ) - exo_hat = as.data.frame( exo_df[i,(1+nb_exos+1):(1+2*nb_exos)] ) + exo_hat = + if (i < nrow(exo_df)) + as.data.frame( exo_df[i+1,(1+nb_exos+1):(1+2*nb_exos)] ) + else + NA #exogenous prediction for next day are useless on last day data$append(time, serie, exo, exo_hat) if (i >= limit) break