From cc5484c4e3c0ebb9b1dfe4a0801a206dc8598ebf Mon Sep 17 00:00:00 2001 From: Julian Carrasquillo Date: Sun, 22 May 2022 13:12:46 -0400 Subject: [PATCH] adding no history error handling to cross_validation (#2140) --- python/prophet/diagnostics.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/python/prophet/diagnostics.py b/python/prophet/diagnostics.py index cbfbc64..c25be97 100644 --- a/python/prophet/diagnostics.py +++ b/python/prophet/diagnostics.py @@ -114,7 +114,10 @@ def cross_validation(model, horizon, period=None, initial=None, parallel=None, c ------- A pd.DataFrame with the forecast, actual value and cutoff. """ - + + if model.history is None: + raise Exception('Model has not been fit. Fitting the model provides contextual parameters for cross validation.') + df = model.history.copy().reset_index(drop=True) horizon = pd.Timedelta(horizon)