From 9003747badc4416d68cab45ff17de3ecea327942 Mon Sep 17 00:00:00 2001
From: Benjamin Auder <benjamin.auder@somewhere>
Date: Wed, 29 Mar 2017 13:39:04 +0200
Subject: [PATCH] attempt to fix F_Neighbors2

---
 .gitignore           | 3 ++-
 pkg/R/F_Neighbors2.R | 6 +++---
 reports/run.sh       | 0
 3 files changed, 5 insertions(+), 4 deletions(-)
 mode change 100644 => 100755 reports/run.sh

diff --git a/.gitignore b/.gitignore
index 2ee5d86..030f5d7 100644
--- a/.gitignore
+++ b/.gitignore
@@ -19,8 +19,9 @@ NAMESPACE
 *.[oa]
 *.so
 
-#jupyter checkpoints + generated HTML
+#jupyter checkpoints + generated ipynb,html
 .ipynb_checkpoints/
+/reports/*.ipynb
 /reports/*.html
 
 #large CSV files
diff --git a/pkg/R/F_Neighbors2.R b/pkg/R/F_Neighbors2.R
index 60916b4..ee40f61 100644
--- a/pkg/R/F_Neighbors2.R
+++ b/pkg/R/F_Neighbors2.R
@@ -46,8 +46,7 @@ Neighbors2Forecaster = R6::R6Class("Neighbors2Forecaster",
 					if (!is.na(prediction[1]))
 					{
 						nb_jours = nb_jours + 1
-						error = error +
-							mean((data$getCenteredSerie(cv_days[i]+1)[1:horizon] - prediction)^2)
+						error = error + mean((data$getSerie(cv_days[i]+1)[1:horizon] - prediction)^2)
 					}
 				}
 				return (error / nb_jours)
@@ -207,10 +206,11 @@ Neighbors2Forecaster = R6::R6Class("Neighbors2Forecaster",
 
 			prediction = rep(0, horizon)
 			for (i in seq_along(fdays))
-				prediction = prediction + similarities[i] * data$getCenteredSerie(fdays[i]+1)[1:horizon]
+				prediction = prediction + similarities[i] * data$getSerie(fdays[i]+1)[1:horizon]
 
 			if (final_call)
 			{
+				prediction = prediction - mean(prediction) #predict centered serie (artificial...)
 				private$.params$weights <- similarities
 				private$.params$indices <- fdays
 				private$.params$window <-
diff --git a/reports/run.sh b/reports/run.sh
old mode 100644
new mode 100755
-- 
2.44.0