prophet
prophet copied to clipboard
Calling `cross_validation(model)` without `model.fit` throws AttributeError
Calling cross_validation(model)
without calling model.fit
first throws AttributeError.
[def cross_validation(model, horizon, period=None, initial=None, parallel=None, cutoffs=None):]()
...
df = model.history.copy().reset_index(drop=True]()
AttributeError: 'NoneType' object has no attribute 'copy']()
- If
fit
is required to be run beforecross_validation
, I would expect an appropriate error to be thrown with an actionable fix by the user. - Assuming that the assumption in 1) is true, why does
fit
have to be called first? As I understand,fit
uses the entire history to fit the model. Even thoughcross_validation
purports to fit using each fold, it's not obvious from the API that the precedingfit
procedure won't cause temporal leakage.
For 1), I agree that there should be a clearer error message, thanks @jul-carras !
For 2), it does seem unintuitive at first (typically the ML workflow is train on subset -> validate -> fit on entire history), but it seems the cross_validation function was designed to:
- Only take a
model
argument and not adataframe
argument. - Pick the largest seasonal period in the data. When the end user instantiates a
Prophet()
object, they may not set seasonalities yet, and these may be inferred later during the fitting process. We can probably scope out a clearer API but just need to keep those two things in mind.