X-Git-Url: https://git.auder.net/?a=blobdiff_plain;ds=sidebyside;f=R%2FgetForecast.R;h=e126946eec7b32215e8d262bf0aa822470303daf;hb=09cf9c19b5c6a04bc23c58b7ac8a4bbae2c6827d;hp=c3248a96f489ec971d30886b46c8b55ef1ebb952;hpb=3d69ff21e577fc7bb082257280661b64536c20e8;p=talweg.git diff --git a/R/getForecast.R b/R/getForecast.R index c3248a9..e126946 100644 --- a/R/getForecast.R +++ b/R/getForecast.R @@ -42,7 +42,7 @@ getForecast = function(data, indices, memory, horizon, horizon = as.integer(horizon)[1] if (horizon<=0 || horizon>length(data$getCenteredSerie(2))) stop("Horizon too short or too long") - indices = as.integer(indices) + indices = sapply( seq_along(indices), function(i) dateIndexToInteger(indices[i], data) ) if (any(indices<=0 | indices>data$getSize())) stop("Indices out of range") indices = sapply(indices, dateIndexToInteger, data) @@ -56,9 +56,6 @@ getForecast = function(data, indices, memory, horizon, pred = list() for (today in indices) { - #NOTE: To estimate timing... -# print(paste("Predict until index",today)) - #shape always predicted first (on centered series, no scaling taken into account), #with side-effect: optimize some parameters (h, weights, ...) predicted_shape = shape_forecaster$predict(today, memory, horizon, ...) @@ -69,7 +66,7 @@ getForecast = function(data, indices, memory, horizon, #TODO: this way is faster than a call to append(); why ? pred[[length(pred)+1]] = list( # Predict shape and align it on end of current day - serie = predicted_shape + tail( data$getSerie(today), 1 ) - predicted_shape[1], + serie = predicted_shape + tail( data$getSerie(today), 1 ) - predicted_shape[1] + predicted_delta, #add predicted jump params = shape_forecaster$getParameters(), index = today )