diff --git a/R/R/diagnostics.R b/R/R/diagnostics.R index 709bb7c..242216d 100644 --- a/R/R/diagnostics.R +++ b/R/R/diagnostics.R @@ -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 diff --git a/python/fbprophet/diagnostics.py b/python/fbprophet/diagnostics.py index 5ca3159..b1d4f3f 100644 --- a/python/fbprophet/diagnostics.py +++ b/python/fbprophet/diagnostics.py @@ -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