From: Benjamin Auder Date: Thu, 18 May 2017 14:06:29 +0000 (+0200) Subject: 'update' X-Git-Url: https://git.auder.net/variants/Chakart/doc/scripts/assets/common.css?a=commitdiff_plain;h=8ab6420267542d34b7428f978aa76ba939b9754b;p=talweg.git 'update' --- diff --git a/pkg/DESCRIPTION b/pkg/DESCRIPTION index ac6dc89..e3a14af 100644 --- a/pkg/DESCRIPTION +++ b/pkg/DESCRIPTION @@ -23,7 +23,7 @@ Suggests: LazyData: yes URL: http://git.auder.net/?p=talweg.git License: MIT + file LICENSE -RoxygenNote: 6.0.1 +RoxygenNote: 5.0.1 Collate: 'plot.R' 'computeError.R' diff --git a/pkg/R/Forecaster.R b/pkg/R/Forecaster.R index 2b259fc..784f86e 100644 --- a/pkg/R/Forecaster.R +++ b/pkg/R/Forecaster.R @@ -59,6 +59,10 @@ Forecaster = R6::R6Class("Forecaster", { # Parameters (potentially) computed during shape prediction stage predicted_shape <- self$predictShape(data,today,memory,predict_from,horizon,...) + + if (is.na(predicted_shape)) + return (NA) + predicted_delta <- if (is.null(private$.pjump)) NULL diff --git a/pkg/R/J_Neighbors.R b/pkg/R/J_Neighbors.R index 2caedc5..ceea803 100644 --- a/pkg/R/J_Neighbors.R +++ b/pkg/R/J_Neighbors.R @@ -18,6 +18,9 @@ getNeighborsJumpPredict = function(data, today, memory, predict_from, horizon, indices = params$indices[filter] weights = params$weights[filter] + if (is.na(indices[1])) + return (NA) + gaps = sapply(indices, function(i) { if (predict_from >= 2) data$getSerie(i)[predict_from] - data$getSerie(i)[predict_from-1] diff --git a/pkg/R/computeForecast.R b/pkg/R/computeForecast.R index c778d66..e1b29b6 100644 --- a/pkg/R/computeForecast.R +++ b/pkg/R/computeForecast.R @@ -27,6 +27,7 @@ #' @param memory Data depth (in days) to be used for prediction. #' @param horizon Last time step to predict. #' @param ncores Number of cores for parallel execution (1 to disable). +#' @param verbose TRUE to print basic traces (runs beginnings) #' @param ... Additional parameters for the forecasting models. #' #' @return An object of class Forecast @@ -60,7 +61,7 @@ #' } } #' @export computeForecast = function(data, indices, forecaster, pjump, predict_from, - memory=Inf, horizon=length(data$getSerie(1)), ncores=3, ...) + memory=Inf, horizon=length(data$getSerie(1)), ncores=3, verbose=FALSE, ...) { # (basic) Arguments sanity checks predict_from = as.integer(predict_from)[1] @@ -89,6 +90,8 @@ computeForecast = function(data, indices, forecaster, pjump, predict_from, computeOneForecast <- function(i) { + if (verbose) + print(paste("Index",i)) list( "forecast" = forecaster$predictSerie(data,i,memory,predict_from,horizon,...), "params" = forecaster$getParameters(),