From 7b9acd953fd4a12ff5fe44a7d4909808cfdcca51 Mon Sep 17 00:00:00 2001 From: Ben Letham Date: Thu, 1 Feb 2018 16:21:57 -0800 Subject: [PATCH] Add error message if make_future_dataframe before fit --- R/R/prophet.R | 3 +++ python/fbprophet/forecaster.py | 2 ++ 2 files changed, 5 insertions(+) diff --git a/R/R/prophet.R b/R/R/prophet.R index 6d36854..2eb4e46 100644 --- a/R/R/prophet.R +++ b/R/R/prophet.R @@ -1379,6 +1379,9 @@ make_future_dataframe <- function(m, periods, freq = 'day', if (freq == 'm') { freq <- 'month' } + if (is.null(m$history.dates)) { + stop('Model must be fit before this can be used.') + } dates <- seq(max(m$history.dates), length.out = periods + 1, by = freq) dates <- dates[2:(periods + 1)] # Drop the first, which is max(history$ds) if (include_history) { diff --git a/python/fbprophet/forecaster.py b/python/fbprophet/forecaster.py index 96937e9..d3cefc8 100644 --- a/python/fbprophet/forecaster.py +++ b/python/fbprophet/forecaster.py @@ -1214,6 +1214,8 @@ class Prophet(object): pd.Dataframe that extends forward from the end of self.history for the requested number of periods. """ + if self.history_dates is None: + raise Exception('Model must be fit before this can be used.') last_date = self.history_dates.max() dates = pd.date_range( start=last_date,