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

Add Multiplicative Models/Seasonals #178

Closed
antoinecarme opened this issue Jan 27, 2022 · 6 comments
Closed

Add Multiplicative Models/Seasonals #178

antoinecarme opened this issue Jan 27, 2022 · 6 comments

Comments

@antoinecarme
Copy link
Owner

antoinecarme commented Jan 27, 2022

PyAF uses an additive signal decomposition of the type \Phi( Trend + Seasonal + AR), where \Phi is a signal transformation.

It is interesting to add multiplicative decompositions to allow more diverse models. A decomposition can be of the form \Phi( Trend * Seasonal + AR) or \Phi( Trend * Seasonal * AR). More general models can be generated this way and allow exploring more forecast types/spaces.

  1. Add Options.mDecompositionTypes = ['T+S+R' , 'TS+R' , 'TSR']. Give control to the user/model. PyAF does not try to detect if the seasonality is additive or multiplicative. It tries all possible models , including both seasonality types and keeps the best model (best MAPE). CPU time is cheap.
  2. Compute incremental remainders/residues based on the decomposition type (trend residues, seasonal residues, etc).
  3. Only 'T+S+R' is enabled by default (fast mode). Slow mode activates all decomposition types. User customizable.
  4. Each decomposition type goes on a specific CPU.
  5. In some cases, multiplicative models are not applicable (negative or zero values in the signal or its residues)

References :

  1. Forecasting: Principles and Practice (3rd ed) By Rob J Hyndman and George Athanasopoulos. https://otexts.com/fpp3/decomposition.html
  2. https://otexts.com/fpp3/classical-decomposition.html

Target Release : 2022-07-14

@antoinecarme
Copy link
Owner Author

Impact on plots ?

@antoinecarme
Copy link
Owner Author

Demo notebook.

antoinecarme added a commit that referenced this issue Jan 31, 2022
antoinecarme added a commit that referenced this issue Jan 31, 2022
Added a dataset for the demo notebook
@antoinecarme
Copy link
Owner Author

First demo dataset : wineind: Australian total wine sales

https://www.rdocumentation.org/packages/forecast/versions/8.1/topics/wineind

antoinecarme added a commit that referenced this issue Mar 5, 2022
Updated Optons. Only additive models are activated by default
antoinecarme added a commit that referenced this issue Mar 5, 2022
Generate all models with all possible decomposition types.
antoinecarme added a commit that referenced this issue Mar 5, 2022
Handle slow mode.
XGBoost and LightGBM models are optional.
antoinecarme added a commit that referenced this issue Mar 5, 2022
Properly compute the final/winning model.
antoinecarme added a commit that referenced this issue Mar 5, 2022
antoinecarme added a commit that referenced this issue Mar 5, 2022
antoinecarme added a commit that referenced this issue Mar 5, 2022
antoinecarme added a commit that referenced this issue Mar 5, 2022
Compute AR/Keras/Intermittent/Scikit models residues
antoinecarme added a commit that referenced this issue Mar 5, 2022
Added some functional tests
antoinecarme added a commit that referenced this issue Mar 5, 2022
antoinecarme added a commit that referenced this issue Mar 6, 2022
Added sample jupyter notebooks with the same dataset and different model settings (T+S+R, TS+R, TSR, slow)
WIP
antoinecarme added a commit that referenced this issue Mar 7, 2022
Compute residues is not that easy!!!
antoinecarme added a commit that referenced this issue Mar 7, 2022
Handle division by zeros in multiplicative models residues.
antoinecarme added a commit that referenced this issue Mar 7, 2022
Added some tests (slooooooow, for debugging purposes)
antoinecarme added a commit that referenced this issue Mar 7, 2022
Disable cross-validation by default in slow mode. Can be reenabled manually.
antoinecarme added a commit that referenced this issue Mar 7, 2022
Update model complexity. Additive models are simpler than multiplicative ones.
antoinecarme added a commit that referenced this issue Mar 7, 2022
Refactored model selection. Probably some issues correcetd with very large models.
Added some backward-compatibility.
antoinecarme added a commit that referenced this issue Mar 7, 2022
@antoinecarme
Copy link
Owner Author

Summary of implementation details :

Updated Options. Only additive models are activated by default
Generate all models with all possible decomposition types.
Handle slow mode. XGBoost and LightGBM models are optional.
Compute trend residues
Compute cycle residues
Compute AR residues
Compute AR/Keras/Intermittent/Scikit models residues
Added some functional tests
Added sample jupyter notebooks with the same dataset and different model settings (T+S+R, TS+R, TSR, slow)
ZeroAR constant value is 1.0 sometimes.
ZeroCycle constant value is 1.0 in multiplicative models
Updated model formula (informative)
Use series.dtype instead of np.dtype(series). CicleCI effects
Corrected typing of intermediate columns.
Avoid unnecessary SettingWithCopyWarning
Handle division by zeros in multiplicative models residues. Compute residues is not that easy!!!
Avoid dataframe fragmentation warnings.
Added some tests (slooooooow, for debugging purposes)
Disable cross-validation by default in slow mode. Can be reenabled manually.
Update model complexity. Additive models are simpler than multiplicative ones.
Refactored model selection. Probably some issues corrected with very large models.

@antoinecarme
Copy link
Owner Author

Added a report on the model selection as a dataframe with the best MAPE models , sorted by complexity.

lEngine.mSignalDecomposition.mModelShortList

image

@antoinecarme
Copy link
Owner Author

Fixed.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant