diff --git a/R/R/prophet.R b/R/R/prophet.R index 591fd16..74ab976 100644 --- a/R/R/prophet.R +++ b/R/R/prophet.R @@ -1305,6 +1305,9 @@ fit.prophet <- function(m, df, ...) { #' #' @export predict.prophet <- function(object, df = NULL, ...) { + if (is.null(object$history)) { + stop("Model must be fit before predictions can be made.") + } if (is.null(df)) { df <- object$history } else { diff --git a/python/fbprophet/forecaster.py b/python/fbprophet/forecaster.py index 1cc6144..8c3afd3 100644 --- a/python/fbprophet/forecaster.py +++ b/python/fbprophet/forecaster.py @@ -1147,6 +1147,9 @@ class Prophet(object): ------- A pd.DataFrame with the forecast components. """ + if self.history is None: + raise Exception('Model must be fit before predictions can be made.') + if df is None: df = self.history.copy() else: