projects
/
talweg.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
TODO: comprendre pkoi pas mêmes voisins
[talweg.git]
/
pkg
/
R
/
F_Neighbors.R
diff --git
a/pkg/R/F_Neighbors.R
b/pkg/R/F_Neighbors.R
index
02536eb
..
60eb7b7
100644
(file)
--- a/
pkg/R/F_Neighbors.R
+++ b/
pkg/R/F_Neighbors.R
@@
-61,8
+61,8
@@
NeighborsForecaster = R6::R6Class("NeighborsForecaster",
if (!opera)
tdays = setdiff(tdays, today) #always exclude current day
if (!opera)
tdays = setdiff(tdays, today) #always exclude current day
- # Shortcut if window is known
- if (hasArg("window"))
+ # Shortcut if window is known
or local==TRUE && simtype==none
+ if (hasArg("window")
|| (local && simtype=="none")
)
{
return ( private$.predictShapeAux(data, tdays, today, predict_from, horizon,
local, list(...)$window, simtype, opera, TRUE) )
{
return ( private$.predictShapeAux(data, tdays, today, predict_from, horizon,
local, list(...)$window, simtype, opera, TRUE) )
@@
-129,8
+129,8
@@
NeighborsForecaster = R6::R6Class("NeighborsForecaster",
if (local)
{
if (local)
{
- #
TODO: 60 == magic number
- tdays = getSimilarDaysIndices(today, data, limit=
60
, same_season=TRUE,
+ #
limit=Inf to not censor any day (TODO: finite limit? 60?)
+ tdays = getSimilarDaysIndices(today, data, limit=
Inf
, same_season=TRUE,
days_in=tdays_cut, operational=opera)
# if (length(tdays) <= 1)
# return (NA)
days_in=tdays_cut, operational=opera)
# if (length(tdays) <= 1)
# return (NA)
@@
-146,6
+146,13
@@
NeighborsForecaster = R6::R6Class("NeighborsForecaster",
}
return ( data$getSerie(tdays[1])[predict_from:horizon] )
}
}
return ( data$getSerie(tdays[1])[predict_from:horizon] )
}
+ max_neighbs = 12 #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] ]
+ }
}
else
tdays = tdays_cut #no conditioning
}
else
tdays = tdays_cut #no conditioning
@@
-156,19
+163,9
@@
NeighborsForecaster = R6::R6Class("NeighborsForecaster",
window_endo = ifelse(simtype=="mix", window[1], window)
# Distances from last observed day to selected days in the past
window_endo = ifelse(simtype=="mix", window[1], window)
# Distances from last observed day to selected days in the past
+ # TODO: redundant computation if local==TRUE
distances2 <- .computeDistsEndo(data, today, tdays, predict_from)
distances2 <- .computeDistsEndo(data, today, tdays, predict_from)
- if (local)
- {
- max_neighbs = 12 #TODO: 12 = arbitrary number
- if (length(distances2) > max_neighbs)
- {
- ordering <- order(distances2)
- tdays <- tdays[ ordering[1:max_neighbs] ]
- distances2 <- distances2[ ordering[1:max_neighbs] ]
- }
- }
-
simils_endo <- .computeSimils(distances2, window_endo)
}
simils_endo <- .computeSimils(distances2, window_endo)
}