pytorch-forecasting icon indicating copy to clipboard operation
pytorch-forecasting copied to clipboard

[ENH] Support tuning any model and extend LSTMModel in docs to support multi-target datasets

Open svnv-svsv-jm opened this issue 1 year ago • 4 comments

Description

This PR fixes my own issues:

  • https://github.com/jdb78/pytorch-forecasting/issues/1440
  • https://github.com/jdb78/pytorch-forecasting/issues/1448

It allows to tune "any" model, generalizing the optimize_hypetparameters function from TemporalFusionTransformer model, and it also add a "better" LSTMModel than the one shown in the documentation, which I tried to use on a multi-target dataset without success. My version does work on multi-target datasets, thanks to an extension to AutoRegressiveBaseModel.

My version of AutoRegressiveBaseModel inherits from the original to override a couple of methods. I should've probably just edited the original, but I'd like to hear your feedback before doing that. I'm also sure there was a simpler way for AutoRegressiveBaseModel to work with multi-target data. When I tried to just run the Documentation's example of LSTMModel but on a multi-target dummy dataset, it just did not work out of the box.

Checklist

  • Linked issues: https://github.com/jdb78/pytorch-forecasting/issues/1440 , https://github.com/jdb78/pytorch-forecasting/issues/1448
  • Amended changelog for large changes (and added myself there as contributor)
  • Added/modified tests: tests/test_models/test_tuning.py
  • [Yes] Used pre-commit hooks when committing to ensure that code is compliant with hooks. Install hooks with pre-commit install. To run hooks independent of commit, execute pre-commit run --all-files

Make sure to have fun coding!

svnv-svsv-jm avatar Nov 22 '23 15:11 svnv-svsv-jm

What's blocking this?

svnv-svsv-jm avatar Jan 03 '24 19:01 svnv-svsv-jm

Check out this pull request on  ReviewNB

See visual diffs & provide feedback on Jupyter Notebooks.


Powered by ReviewNB

I don't understand why the docs test fails (I haven't changed anything there) and why the Black test fails if I ran black and on my machine black --check . returns:

>> black --check .
All done! ✨ 🍰 ✨
54 files would be left unchanged.

svnv-svsv-jm avatar Feb 13 '24 22:02 svnv-svsv-jm

Codecov Report

Attention: 35 lines in your changes are missing coverage. Please review.

Comparison is base (b3fcf86) 90.19% compared to head (652a4c1) 89.96%. Report is 8 commits behind head on master.

Files Patch % Lines
pytorch_forecasting/models/_base_autoregressive.py 77.46% 16 Missing :warning:
pytorch_forecasting/models/tuning.py 85.43% 15 Missing :warning:
pytorch_forecasting/data/timeseries.py 0.00% 3 Missing :warning:
pytorch_forecasting/models/lstm.py 98.83% 1 Missing :warning:

:exclamation: Your organization needs to install the Codecov GitHub app to enable full functionality.

Additional details and impacted files
@@            Coverage Diff             @@
##           master    #1449      +/-   ##
==========================================
- Coverage   90.19%   89.96%   -0.23%     
==========================================
  Files          30       33       +3     
  Lines        4724     4985     +261     
==========================================
+ Hits         4261     4485     +224     
- Misses        463      500      +37     
Flag Coverage Δ
cpu 89.96% <86.79%> (-0.23%) :arrow_down:
pytest 89.96% <86.79%> (-0.23%) :arrow_down:

Flags with carried forward coverage won't be shown. Click here to find out more.

:umbrella: View full report in Codecov by Sentry.
:loudspeaker: Have feedback on the report? Share it here.

codecov-commenter avatar Feb 13 '24 22:02 codecov-commenter