diff --git a/R/R/prophet.R b/R/R/prophet.R index bbd4a49..4f33913 100644 --- a/R/R/prophet.R +++ b/R/R/prophet.R @@ -473,6 +473,9 @@ logistic_growth_init <- function(df) { #' #' @export fit.prophet <- function(m, df, ...) { + if (!is.null(m$history)) { + stop("Prophet object can only be fit once. Instantiate a new object.") + } history <- df %>% dplyr::filter(!is.na(y)) m$history.dates <- sort(zoo::as.Date(df$ds)) diff --git a/python/fbprophet/forecaster.py b/python/fbprophet/forecaster.py index 65529be..919b587 100644 --- a/python/fbprophet/forecaster.py +++ b/python/fbprophet/forecaster.py @@ -479,6 +479,9 @@ class Prophet(object): ------- The fitted Prophet object. """ + if self.history is not None: + raise Exception('Prophet object can only be fit once. ' + 'Instantiate a new object.') history = df[df['y'].notnull()].copy() self.history_dates = pd.to_datetime(df['ds']).sort_values()