Skip to content

fix(models): score the in-memory model without reloading the checkpoint - #504

Merged
mkumar73 merged 3 commits into
mainfrom
fix/regressor-score-reload
Nov 30, 2026
Merged

mkumar73 merged 3 commits into
mainfrom
fix/regressor-score-reload

Conversation

@ChrisW09

@ChrisW09 ChrisW09 commented Oct 21, 2026 •

Copy link
Copy Markdown
Collaborator

Fixes #503

Problem

_PredictMixin._score, which backs SklearnBaseRegressor.score(), loaded _best_model_path from disk into the task model before predicting. fit() already restores that checkpoint before returning, so the reload added nothing and caused two problems:

  • score() raised FileNotFoundError once the checkpoint directory had been removed, even though predict() worked.
  • score() silently replaced any weights changed after fit() with the checkpoint's.

Fix

_score now just predicts with the current model and applies the metric, the same as predict(), evaluate() and the classifiers' score(). The docstring now describes this.

Tests

tests/integration/test_fit_lifecycle.py::TestRegressorScoreUsesCurrentModel:

  • test_score_works_after_checkpoint_directory_is_removed
  • test_score_does_not_replace_current_weights: score() equals the R² of the current predictions, and predictions are unchanged afterwards.

Both fail on main and pass with this change.

Docs

The _score docstring and the _PredictMixin overview, which still said _score reloads the best checkpoint for optimize_hparams, are updated. No user-facing page described the reload.

Checks

  • just test: 3238 passed, 46 skipped, 28 xfailed; coverage 91.29%
  • just docs: build succeeded (warnings treated as errors)
  • just check: all hooks passed (ruff, prettier, pyright)

_PredictMixin._score (used by the regressors' score()) loaded the best
checkpoint from disk into the task model before predicting. fit() has
already restored that checkpoint, so the reload only made score() fail
with FileNotFoundError once the checkpoint directory was removed and
silently replaced any weights changed after fitting.

Score the current model, like predict() and the classifiers' score().

Fixes #503
@mkumar73 mkumar73 self-assigned this Nov 30, 2026
@mkumar73
mkumar73 merged commit e54252c into main Nov 30, 2026
35 checks passed
@mkumar73
mkumar73 deleted the fix/regressor-score-reload branch November 30, 2026 07:25
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[BUG] Regressor score() reloads the training checkpoint from disk: fails when it is gone and overwrites the current weights

2 participants