Thanks to visit codestin.com
Credit goes to Github.com

Skip to content

[ENH] support for neuralforecast new versions#8750

Merged
fkiraly merged 21 commits intosktime:mainfrom
thisisrick25:thisisrick25/issue8742
Jan 3, 2026
Merged

[ENH] support for neuralforecast new versions#8750
fkiraly merged 21 commits intosktime:mainfrom
thisisrick25:thisisrick25/issue8742

Conversation

@thisisrick25
Copy link
Contributor

@thisisrick25 thisisrick25 commented Aug 25, 2025

Reference Issues/PRs

Closes #8742

What does this implement/fix? Explain your changes.

  • 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.
  • Ensure backward compatibility with neuralforecast versions prior to 3.0.0.
  • Adjust h parameter 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
  • I've added myself to the list of contributors with any new badges I've earned :-)
    How to: add yourself to the all-contributors file in the sktime root directory (not the CONTRIBUTORS.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 plus code if you also fixed the bug in the PR).maintenance - CI, test framework, release.
    See here for full badge reference
  • Optionally, for added estimators: I've added myself and possibly to the maintainers tag - 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.
  • The PR title starts with either [ENH], [MNT], [DOC], or [BUG]. [BUG] - bugfix, [MNT] - CI, test framework, [ENH] - adding or improving code, [DOC] - writing or improving documentation or docstrings.
For new estimators
  • I've added the estimator to the API reference - in docs/source/api_reference/taskname.rst, follow the pattern.
  • I've added one or more illustrative usage examples to the docstring, in a pydocstyle compliant Examples section.
  • If the estimator relies on a soft dependency, I've set the python_dependencies tag and ensured
    dependency isolation, see the estimator dependencies guide.

- 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.
Copy link
Member

@yarnabrina yarnabrina left a comment

Choose a reason for hiding this comment

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

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.

@fkiraly
Copy link
Collaborator

fkiraly commented Aug 25, 2025

Also sktime already has version check utilities, you can reuse.

from sktime.utils.dependencies import _check_soft_dependencies

@thisisrick25
Copy link
Contributor Author

Thanks @fkiraly, I did figured out _check_soft_dependencies, I have reverted the changes and will add _check_soft_dependencies.

- 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.
@fkiraly
Copy link
Collaborator

fkiraly commented Aug 25, 2025

Great! Have you tested that this works on newer and older versions?

Copilot AI review requested due to automatic review settings December 18, 2025 06:22
Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

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

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_dependencies to 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.

@thisisrick25
Copy link
Contributor Author

thisisrick25 commented Dec 22, 2025

@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.
Fixing the failing CI tests took the most time; from my understanding, they were failing because the _predict() method in _neuralforecast.py is incompatible with NF v3 output format.
I found in the documentation that, in NF v3, predict() returns unique_id and ds as columns (not as DataFrame index), but sktime assumed these were in the DataFrame index.

Nixtla/neuralforecast#1023
https://github.com/Nixtla/neuralforecast/blob/main/neuralforecast/core.py#L1089
https://nixtla.github.io/neuralforecast1/core.html#neuralforecast
https://nixtlaverse.nixtla.io/neuralforecast/core.html#neuralforecast-predict

I still couldnt figure out why mlflow test is failing.

@fkiraly fkiraly added module:forecasting forecasting module: forecasting, incl probabilistic and hierarchical forecasting enhancement Adding new functionality labels Jan 3, 2026
Copy link
Collaborator

@fkiraly fkiraly left a comment

Choose a reason for hiding this comment

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

Thanks - the mlflow failures were unrelated.

@fkiraly fkiraly merged commit c2daca3 into sktime:main Jan 3, 2026
261 of 263 checks passed
@thisisrick25
Copy link
Contributor Author

Hi @fkiraly i forgot to add myself in the list of contributors, should I open a new PR for this or hold on for future issues I work on?

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

None yet

Development

Successfully merging this pull request may close these issues.

[ENH] support for neuralforecast new versions

3 participants

Comments