[ENH] support for neuralforecast new versions#8750
Conversation
- Implement version-specific logic to support neuralforecast v3.0.0+. - Address the input_size parameter becoming mandatory for recurrent models (RNN, LSTM, GRU) in neuralforecast v3.0.0+. - Update pyproject.toml to allow neuralforecast versions up to <4.0.0. - Ensure backward compatibility with neuralforecast versions prior to 3.0.0. - Adjust h parameter usage for consistency with neuralforecast v3.0.0+ API.
- Reorder parse_version import statement for better organization. - Shorten comment reference from "neuralforecast v3" to "NF v3". - This change has no functional impact on the adapter's behavior.
yarnabrina
left a comment
There was a problem hiding this comment.
Thanks for working on this. While a general adapter instead of a model specific one is preferable, I'll suggest not to change the class behaviour by algorithm name based check.
Also sktime already has version check utilities, you can reuse.
|
This reverts commit 9bab319.
|
Thanks @fkiraly, I did figured out |
- The neuralforecast library introduced breaking changes in its NeuralForecast class constructor in version 3.0.0. - Parameter names for models and scaler_type were updated, and local_scaler_type was renamed to scaler_type. - This change implements a version check to dynamically initialize NeuralForecast with the correct parameters. - Ensures sktime's _NeuralForecastAdapter remains compatible with both neuralforecast versions < 3.0.0 and >= 3.0.0. - Replaces pkg_resources with _check_soft_dependencies for version checking.
|
Great! Have you tested that this works on newer and older versions? |
There was a problem hiding this comment.
Pull request overview
This PR adds version-specific support for neuralforecast v3.0.0 while maintaining backward compatibility with earlier versions. The main change implements conditional logic to handle API changes in the NeuralForecast class instantiation.
Key Changes
- Adds version detection using
_check_soft_dependenciesto differentiate between neuralforecast <3.0.0 and ≥3.0.0 - Updates NeuralForecast class instantiation parameters for v3.0.0 (uses named parameters:
models=,freq=,scaler_type=) - Maintains compatibility with pre-3.0.0 versions (uses positional parameters and
local_scaler_type=)
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
…cast models and update `pyproject.toml`.
…ze and global forecasting fix
|
@fkiraly I have spent some time working on this; Yes I have tested this locally, and it works on both newer and older versions of NF. Nixtla/neuralforecast#1023 I still couldnt figure out why mlflow test is failing. |
fkiraly
left a comment
There was a problem hiding this comment.
Thanks - the mlflow failures were unrelated.
|
Hi @fkiraly i forgot to add myself in the |
Reference Issues/PRs
Closes #8742
What does this implement/fix? Explain your changes.
input_sizeparameter becoming mandatory for recurrent models (RNN, LSTM, GRU) in neuralforecast v3.0.0.hparameter usage for consistency with neuralforecast v3.0.0 API.Does your contribution introduce a new dependency? If yes, which one?
What should a reviewer concentrate their feedback on?
Did you add any tests for the change?
Any other comments?
PR checklist
For all contributions
How to: add yourself to the all-contributors file in the
sktimeroot directory (not theCONTRIBUTORS.md). Common badges:code- fixing a bug, or adding code logic.doc- writing or improving documentation or docstrings.bug- reporting or diagnosing a bug (get this pluscodeif you also fixed the bug in the PR).maintenance- CI, test framework, release.See here for full badge reference
maintainerstag - do this if you want to become the owner or maintainer of an estimator you added.See here for further details on the algorithm maintainer role.
For new estimators
docs/source/api_reference/taskname.rst, follow the pattern.Examplessection.python_dependenciestag and ensureddependency isolation, see the estimator dependencies guide.