investigations on Bruno vs. talweg: a shift overved, and neighbors differ (a bit...
[talweg.git] / pkg / R / F_Neighbors.R
index 60eb7b7..d63c177 100644 (file)
@@ -146,12 +146,18 @@ NeighborsForecaster = R6::R6Class("NeighborsForecaster",
                                        }
                                        return ( data$getSerie(tdays[1])[predict_from:horizon] )
                                }
-                               max_neighbs = 12 #TODO: 12 = arbitrary number
+                               max_neighbs = 10 #TODO: 12 = arbitrary number
                                if (length(tdays) > max_neighbs)
                                {
                                        distances2 <- .computeDistsEndo(data, today, tdays, predict_from)
                                        ordering <- order(distances2)
                                        tdays <- tdays[ ordering[1:max_neighbs] ]
+
+                                       print("VVVVV")
+                                       print(sort(distances2)[1:max_neighbs])
+                                       print(integerIndexToDate(today,data))
+                                       print(lapply(tdays,function(i) integerIndexToDate(i,data)))
+                                       print(rbind(data$getSeries(tdays-1), data$getSeries(tdays)))
                                }
                        }
                        else
@@ -281,7 +287,8 @@ NeighborsForecaster = R6::R6Class("NeighborsForecaster",
        sapply(tdays, function(i) {
                delta = lastSerie - c(data$getSerie(i-1),
                        data$getSerie(i)[if (predict_from>=2) 1:(predict_from-1) else c()])
-               sqrt(mean(delta^2))
+#              sqrt(mean(delta^2))
+               sqrt(sum(delta^2))
        })
 }