[BUG] preliminary fix for incorrect setting of _pretrained_attrs in case __init__ already sets fitted attrs#10535
Merged
Conversation
fkiraly
marked this pull request as ready for review
July 11, 2026 16:07
fkiraly
requested review from
SimonBlanke,
benHeid,
felipeangelimvieira,
geetu040,
jgyasu and
marrov
as code owners
July 11, 2026 16:07
There was a problem hiding this comment.
Pull request overview
This PR implements a preliminary fix to BaseForecaster.pretrain so that _pretrained_attrs only tracks attributes that first appear during pretrain, avoiding misclassification of fitted-style attributes that were already present when entering pretrain (e.g., attributes initialized in __init__). It also adds a regression test targeting the reported behavior in #10531.
Changes:
- Capture public trailing-underscore attributes present at
pretrainentry and exclude them from_pretrained_attrs. - Add a regression test ensuring
NaiveForecaster.pretraindoes not register pre-existing attrs as pretrained params.
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 2 comments.
| File | Description |
|---|---|
| sktime/forecasting/base/_base.py | Excludes pre-existing public *_ attributes from being added to _pretrained_attrs during pretrain. |
| sktime/forecasting/base/tests/test_base.py | Adds regression coverage to ensure pretrain doesn’t misclassify pre-existing attrs as pretrained. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Bug #10531 is triggered in case
__init__already sets fitted attrs, e.g., for initialization (the diagnosis in the issue is incorrect, see discussion below).This PR adds a preliminary fix: only those attrs are added to
self._pretrained_attrsthat do not already exist oncepretrainis entered.A test for regression is also added.
For a final fix, an API design discussion needs to be reopened first.