Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fit model before historical forecast method? #1639

Closed
ETTAN93 opened this issue Mar 9, 2023 · 3 comments
Closed

Fit model before historical forecast method? #1639

ETTAN93 opened this issue Mar 9, 2023 · 3 comments
Labels
bug Something isn't working question Further information is requested triage Issue waiting for triaging

Comments

@ETTAN93
Copy link

ETTAN93 commented Mar 9, 2023

Do I actually need to fit the model before implementing the historical forecast method? From what I understand, even if you do not fit the model, if retrain is set to False, the historical forecast method already fits the model once.

However, if I do not fit the model before historical forecast, I notice that setting retrain = False or setting retrain = True makes no difference in the speed of the method. If I do fit the model before, then it makes a difference.

Is that expected?

@ETTAN93 ETTAN93 added bug Something isn't working triage Issue waiting for triaging labels Mar 9, 2023
@madtoinou
Copy link
Collaborator

Hi,

This is a duplicate of #1617, it is the expected behavior introduced by #1465 to avoid mutating the underlying model object. You indeed should fit() the model before using historical_forecasts.

The model gets retrained because it was not fit before (Darts requires the models to be fit before prediction), regardless of the retrain argument value.

@madtoinou madtoinou added the question Further information is requested label Mar 10, 2023
@ETTAN93
Copy link
Author

ETTAN93 commented Mar 13, 2023

@madtoinou thanks for letting me know. just to be sure I got the methodology right, do I fit on the entire dataset that I have before doing historical forecast or do I only fit on the training set, i.e. between start_date and split_date, that is used by the historical forecast?

@dennisbader
Copy link
Collaborator

If you split your data into train and test split with my_series.split_before(split_point=split_date), then use split_date as your start in historical forecasts. This will perform historical forecasts only on your validation set (the train set is ignored).

# split series into train and test set
train_series, test_series = my_series.split_before(split_point=split_date)

# fit your model on train set
model.fit(train_series)

# perform historical forecasts on val set by setting `start=split_date` (use the original series)
model.historical_forecasts(series=my_series, ..., start=split_date, retrain=False)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working question Further information is requested triage Issue waiting for triaging
Projects
None yet
Development

No branches or pull requests

3 participants