'Added checks to cutoffs and error messages if checks fail using ValueError. Fixed earlier bug' (#1718)

* Update error message: Dataframe has no rows #1650, added err msgs

* Added error messages and checks for cutoffs"
This commit is contained in:
Sharon Woo 2020-11-07 13:46:01 +08:00 committed by GitHub
parent 97bb057de4
commit 4f34de0363
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -140,6 +140,13 @@ def cross_validation(model, horizon, period=None, initial=None, parallel=None, c
# Compute Cutoffs
cutoffs = generate_cutoffs(df, horizon, initial, period)
else:
# add validation of the cutoff to make sure that the min cutoff is strictly greater than the min date in the history
if min(cutoffs) <= df['ds'].min():
raise ValueError("Minimum cutoff value is not strictly greater than min date in history")
# max value of cutoffs is <= (end date minus horizon)
end_date_minus_horizon = df['ds'].max() - horizon
if max(cutoffs) > end_date_minus_horizon:
raise ValueError("Maximum cutoff value is greater than end date minus horizon, no value for cross-validation remaining")
initial = cutoffs[0] - df['ds'].min()
# Check if the initial window