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

[ENH] MultiplexForecaster compatibility with multivariate, probabilistic and hierarchical forecasting #2458

Merged
merged 26 commits into from Apr 28, 2022

Conversation

fkiraly
Copy link
Collaborator

@fkiraly fkiraly commented Apr 13, 2022

This PR partially resolves #1364 and #2088, it enables MultiplexForecaster to work with multivariate, hierarchical, and/or probabilistic forecasters.

This is achieved by replacing manual loopthrough with:

  • tag cloning
  • delegation via the general _DelegatedForecaster (which includes the probabilistic methods and will also pick up any future method that is added)

This PR also contains:

  • docstring improvements in the _HeterogeneousMetaEstimator
  • a docstring fix, added missing default value for parameter deep in get_params throughout the code base

This PR depends on:

@fkiraly fkiraly requested a review from aiwalter as a code owner April 13, 2022 20:05
@fkiraly fkiraly added module:forecasting forecasting module: forecasting, incl probabilistic and hierarchical forecasting refactor Restructuring without changing its external behavior. Neither fixing a bug nor adding a feature. enhancement Adding new functionality and removed refactor Restructuring without changing its external behavior. Neither fixing a bug nor adding a feature. labels Apr 13, 2022
@fkiraly
Copy link
Collaborator Author

fkiraly commented Apr 14, 2022

test_update_predict_predicted_index, my old friend.

The test is failing by cutoff indices not moving (being multiple times the same thing) in the update_predict function.

I am starting to think there is probably some bug in the legacy function _predict_moving_cutoff.

Investigating by refactor, here: #2466

@fkiraly
Copy link
Collaborator Author

fkiraly commented Apr 22, 2022

@miraep8, look what you did!
😱

@fkiraly
Copy link
Collaborator Author

fkiraly commented Apr 22, 2022

image

@miraep8
Copy link
Collaborator

miraep8 commented Apr 22, 2022

Nice!! Not that I am rooting for the bugs here, but it is actually quite satisfying (and surprising!) that the test suite proved to be somewhat useful so quickly. 😄 It seems it was the simpler test you suggested that actually caught it! 👍

@fkiraly
Copy link
Collaborator Author

fkiraly commented Apr 22, 2022

that the test suite proved to be somewhat useful so quickly

I guess there is a lesson about testing in there somewhere, although I'm not quite sure what it is...

Copy link
Collaborator

@miraep8 miraep8 left a comment

Choose a reason for hiding this comment

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

Overall think the changes generally make a lot of sense! I think the HeterogeneousEnsembleForecaster class doesn't add too much here, and should be easy to replace without causing any user side issues (ie we aren't losing any "public" classes). I also think using the _Delegate_Forecaster class seems clever, though does make the code a bit more convoluted. There weren't any obvious issues with the implementation that I spotted. Personally one thing that I would request though would be the addition of a test case that ensures that MultiplexForecaster is in fact now compatible with multivariate/probabilistic/hierarchical forecasting. (ie - just testing one should be fine to make sure the tag cloning has desired effect!)

sktime/forecasting/compose/_multiplexer.py Outdated Show resolved Hide resolved
sktime/base/_meta.py Outdated Show resolved Hide resolved
sktime/forecasting/compose/_multiplexer.py Show resolved Hide resolved
sktime/forecasting/compose/_multiplexer.py Outdated Show resolved Hide resolved
sktime/forecasting/compose/_multiplexer.py Show resolved Hide resolved
sktime/forecasting/compose/_multiplexer.py Show resolved Hide resolved
sktime/forecasting/compose/_multiplexer.py Show resolved Hide resolved
sktime/forecasting/compose/_multiplexer.py Show resolved Hide resolved
fkiraly added a commit that referenced this pull request Apr 27, 2022
Provides the functionality discussed in #1614, i.e., a `reset` method in `BaseObject` that resets attributes and internal state of an estimator/object to its post-`__init__` state (while keeping parameters), equivalent to overwriting `self` with a `sklearn.clone`.

This is motivated by the bug in `MultiplexForecaster` which @miraep8's test suite uncovered in combination with #2458, and the observation that:
* boilerplate needs to be copied from `__init__` to `_fit` to fix it, and
* that the same issue possibly exists in a number of other composites which are not tested for subsequent `fit` with different parameters.

This PR also adds `reset` at the start of `BaseForecaster.fit`, addressing a family of potential bugs where not initializing in `_fit` causes unexpected behaviour in a sequence of calls `__init__`, `set_params`, `fit` (the bug present in the original #2458).
@fkiraly
Copy link
Collaborator Author

fkiraly commented Apr 27, 2022

FYI @miraep8, I now removed _fit, since the reset functionality is now on main and reset is done at the start of fit.

@fkiraly fkiraly merged commit e77249f into main Apr 28, 2022
@fkiraly fkiraly deleted the multiplexer-proba branch April 28, 2022 14:55
@fkiraly fkiraly moved this from Must have to Done in Release v0.14.0 Apr 28, 2022
@miraep8 miraep8 mentioned this pull request Jun 1, 2022
4 tasks
fkiraly pushed a commit that referenced this pull request Jun 10, 2022
Implements a `MultiplexTransformer`. Related to #2670 and #2459.  Note this implementation is meant to be very similar to how `MultiplexForecaster` currently works - see #2458 making use of the `_DelegatedTransformer` in #2612.

With `MultiplexTransformer` one now in theory has a new way to multiplex over multiple transformers.  (Note one could optionally include various transformers with the pre-existing `OptionalPassthrough` but `MultiplexTransformer` should be useful when people want exactly one transformer.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement Adding new functionality module:forecasting forecasting module: forecasting, incl probabilistic and hierarchical forecasting
Projects
Development

Successfully merging this pull request may close these issues.

[ENH] forecasting: ensure compositors (pipeline, tuning) work for multivariate forecasters
3 participants