'update'
authorBenjamin Auder <benjamin.auder@somewhere>
Thu, 18 May 2017 14:06:29 +0000 (16:06 +0200)
committerBenjamin Auder <benjamin.auder@somewhere>
Thu, 18 May 2017 14:06:29 +0000 (16:06 +0200)
pkg/DESCRIPTION
pkg/R/Forecaster.R
pkg/R/J_Neighbors.R
pkg/R/computeForecast.R

index ac6dc89..e3a14af 100644 (file)
@@ -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'
index 2b259fc..784f86e 100644 (file)
@@ -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
index 2caedc5..ceea803 100644 (file)
@@ -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]
index c778d66..e1b29b6 100644 (file)
@@ -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(),