Skip to content

FIX Do not make MLPRegressor.partial_fit accessible with solver=lbfgs - #35137

Merged
lesteve merged 2 commits into
scikit-learn:mainfrom
cosimo17:bug-fix/fix-mlpregressor-partial-fit
Oct 14, 2026
Merged

lesteve merged 2 commits into
scikit-learn:mainfrom
cosimo17:bug-fix/fix-mlpregressor-partial-fit

Conversation

@cosimo17

Copy link
Copy Markdown
Contributor

Reference Issues/PRs

Fixes #35115

What does this implement/fix? Explain your changes.

MLPRegressor(solver="lbfgs") incorrectly exposes partial_fit
because its available_if predicate returns the bound _check_solver
method instead of calling it.

This change calls _check_solver(), making partial_fit unavailable
for lbfgs, consistent with MLPClassifier.

The regression test covers both estimators with sgd, adam, and
lbfgs. It checks method availability and verifies that attempting
to call partial_fit with lbfgs raises AttributeError.

Introduce yourself

I am an algorithm engineer, and I have recently been using scikit-learn to build some machine learning models

AI usage disclosure

I used AI assistance for:

  • Code generation for the decorator fix
  • Regression test generation
  • Development environment setup and local validation

Any other comments?

Local validation:

  • With the original decorator, the new regression test reports
    1 failure (MLPRegressor with lbfgs) and 5 passes.
  • With the fix, all 6 regression test cases pass.
  • The complete test_mlp.py module reports 65 passed, with no skipped tests.
  • Ruff, formatting, Pyrefly, spelling, and whitespace checks pass.
  • pip check and git diff --check pass.

This pull request includes code written with the assistance of AI(GPT-6.1 SOL).
I have personally reviewed the code and understand the fix.

@github-actions

Copy link
Copy Markdown

Thank you for opening your first pull request to scikit-learn! 🎉

To help get your contribution reviewed, please make sure that:

  • You have filled out the pull request template.

  • The pull request addresses an existing issue that is ready for contribution (e.g. not tagged as 'Needs Triage', 'Needs Decision', ...). If you are proposing a new feature, please open an issue to discuss it first.

  • There are no other open pull requests already targeting the same issue.

  • You have followed the pull request checklist. In particular, linting and tests should pass.

@cosimo17
cosimo17 force-pushed the bug-fix/fix-mlpregressor-partial-fit branch from f3f800c to 01fbfc8 Compare October 13, 2026 09:13

@cakedev0 cakedev0 left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

LGTM

@cakedev0 cakedev0 added Quick Review For PRs that are quick to review Waiting for Second Reviewer First reviewer is done, need a second one! labels Oct 13, 2026
@lesteve lesteve changed the title FIX Hide MLPRegressor.partial_fit when solver=lbfgs FIX Do not make MLPRegressor.partial_fit accessible with solver=lbfgs Oct 14, 2026

@lesteve lesteve left a comment •

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

LGTM, thanks for the fix!

About the original bug: oopsy as we say in technical terms 😅

@lesteve
lesteve merged commit 0d4fe14 into scikit-learn:main Oct 14, 2026
49 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

module:neural_network Quick Review For PRs that are quick to review Waiting for Second Reviewer First reviewer is done, need a second one!

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[BUG] MLPRegressor incorrectly exposes partial_fit when solver="lbfgs"

3 participants