Skip to content

Implement forecast decomposition for SMA-based models #1180

Merged
merged 17 commits into from
Mar 29, 2023

Conversation

alex-hse-repository
Copy link
Collaborator

@alex-hse-repository alex-hse-repository commented Mar 23, 2023

Before submitting (must do checklist)

  • Did you read the contribution guide?
  • Did you update the docs? We use Numpy format for all the methods and classes.
  • Did you write any new necessary tests?
  • Did you update the CHANGELOG?

Proposed Changes

Closing issues

closes #1166

@alex-hse-repository alex-hse-repository changed the title Issue 1166 Implement forecast decomposition for SMA-based models Mar 23, 2023
@alex-hse-repository alex-hse-repository self-assigned this Mar 23, 2023
@github-actions
Copy link

github-actions bot commented Mar 23, 2023

@github-actions github-actions bot temporarily deployed to pull request March 23, 2023 13:51 Inactive
@codecov-commenter
Copy link

codecov-commenter commented Mar 23, 2023

Codecov Report

Merging #1180 (97a0b74) into master (aa1f9c1) will increase coverage by 18.51%.
The diff coverage is 100.00%.

📣 This organization is not using Codecov’s GitHub App Integration. We recommend you install it so Codecov can continue to function properly for your repositories. Learn more

@@             Coverage Diff             @@
##           master    #1180       +/-   ##
===========================================
+ Coverage   69.13%   87.64%   +18.51%     
===========================================
  Files         177      177               
  Lines       10380    10394       +14     
===========================================
+ Hits         7176     9110     +1934     
+ Misses       3204     1284     -1920     
Impacted Files Coverage Δ
etna/models/moving_average.py 100.00% <ø> (ø)
etna/models/naive.py 100.00% <ø> (ø)
etna/transforms/math/scalers.py 100.00% <ø> (ø)
etna/datasets/tsdataset.py 92.72% <100.00%> (+18.98%) ⬆️
etna/models/seasonal_ma.py 100.00% <100.00%> (+35.29%) ⬆️
etna/transforms/math/differencing.py 97.76% <100.00%> (ø)
etna/transforms/math/lags.py 100.00% <100.00%> (ø)

... and 66 files with indirect coverage changes

📣 We’re building smart automated test selection to slash your CI/CD build times. Learn more

@github-actions github-actions bot temporarily deployed to pull request March 23, 2023 16:50 Inactive
etna/models/seasonal_ma.py Outdated Show resolved Hide resolved
etna/models/seasonal_ma.py Outdated Show resolved Hide resolved
tests/test_models/test_simple_models.py Outdated Show resolved Hide resolved
tests/test_models/test_simple_models.py Outdated Show resolved Hide resolved
tests/test_models/test_simple_models.py Outdated Show resolved Hide resolved
tests/test_models/test_simple_models.py Show resolved Hide resolved
etna/models/seasonal_ma.py Outdated Show resolved Hide resolved
etna/models/seasonal_ma.py Outdated Show resolved Hide resolved
etna/models/seasonal_ma.py Outdated Show resolved Hide resolved
etna/models/seasonal_ma.py Outdated Show resolved Hide resolved
etna/models/seasonal_ma.py Show resolved Hide resolved
@github-actions github-actions bot temporarily deployed to pull request March 27, 2023 13:39 Inactive
ts.df.loc[:, pd.IndexSlice[:, "target"]] = y_pred

if return_components:
df.loc[-prediction_size:, pd.IndexSlice[:, "target"]] = y_pred
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We still use df.loc[-prediction_size:, pd.IndexSlice[:, "target"]], this probably won't work on all pandas versions (we have error in testing under different pandas versions).

The :prediction_size implies that first index is integer, but it isn't.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sorry, missed this place, you are right. Fixed it

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

May be we should make it more clear why in forecast we add y_pred into df. Because autoregression logic lies within def _forecast and isn't present on level of def forecast.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Or we should make it more clear what kind of df we are going to use inside _predict_components. We require that it contains lags that was used to make a prediction (taking into account auto-regression), it isn't clear.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Add docstring to _predict_components with description of df

etna/models/seasonal_ma.py Show resolved Hide resolved
etna/models/seasonal_ma.py Show resolved Hide resolved
etna/models/seasonal_ma.py Show resolved Hide resolved
brsnw250
brsnw250 previously approved these changes Mar 28, 2023
@github-actions github-actions bot temporarily deployed to pull request March 28, 2023 14:30 Inactive

Notes
-----
This model supports in-sample and out-of-sample prediction decomposition.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This model supports in-sample and out-of-sample prediction decomposition.

I'm not sure that it is an implementation detail and should be in Notes.

Prediction components are corresponding target lags with weights of 1/window

May it could be better to write :math:1 / window

@github-actions github-actions bot temporarily deployed to pull request March 29, 2023 06:09 Inactive
Mr-Geekman
Mr-Geekman previously approved these changes Mar 29, 2023
@alex-hse-repository alex-hse-repository enabled auto-merge (squash) March 29, 2023 07:52
@github-actions github-actions bot temporarily deployed to pull request March 29, 2023 07:56 Inactive
@github-actions github-actions bot temporarily deployed to pull request March 29, 2023 08:40 Inactive
@alex-hse-repository alex-hse-repository merged commit 2a2e96e into master Mar 29, 2023
@Mr-Geekman Mr-Geekman deleted the issue-1166 branch March 29, 2023 11:08
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Implement forecast decomposition for SMA-based models
4 participants