Fix bug in changepoint handling in prophet_copy (#1529)

This commit is contained in:
Ben Letham 2020-08-17 16:24:34 -07:00
parent fb6552137c
commit a519043f1b
2 changed files with 5 additions and 3 deletions

View file

@ -181,7 +181,8 @@ prophet_copy <- function(m, cutoff = NULL) {
changepoints <- m$changepoints
if (!is.null(cutoff)) {
cutoff <- set_date(cutoff)
changepoints <- changepoints[changepoints <= cutoff]
last_history_date <- max(m$history$ds[m$history$ds <= cutoff])
changepoints <- changepoints[changepoints < last_history_date]
}
} else {
changepoints <- NULL

View file

@ -268,8 +268,9 @@ def prophet_copy(m, cutoff=None):
if m.specified_changepoints:
changepoints = m.changepoints
if cutoff is not None:
# Filter change points '<= cutoff'
changepoints = changepoints[changepoints <= cutoff]
# Filter change points '< cutoff'
last_history_date = max(m.history['ds'][m.history['ds'] <= cutoff])
changepoints = changepoints[changepoints < last_history_date]
else:
changepoints = None