Skip to content

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

Closed

Description

@cosimo17

Introduce yourself

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

Describe the bug and give evidence about its user-facing impact

In scikit-learn 1.9.1, MLPRegressor(solver="lbfgs") incorrectly exposes and allows calls to partial_fit(), although L-BFGS does not support incremental training.

Additional evidence: With the same solver configuration, MLPClassifier does not expose partial_fit(), whereas MLPRegressor does. This creates inconsistent behavior between the two estimators.

This may mislead the user.

Steps/Code to Reproduce

from sklearn.neural_network import MLPClassifier, MLPRegressor

print(hasattr(MLPClassifier(solver="lbfgs"), "partial_fit"))
print(hasattr(MLPRegressor(solver="lbfgs"), "partial_fit"))

Expected Results

False
False

Actual Results

False
True

Versions

System:
    python: 3.12.12 | packaged by Anaconda, Inc. | (main, Oct 21 2025, 20:05:38) [MSC v.1929 64 bit (AMD64)]
executable: D:\conda\envs\py312\python.exe
   machine: Windows-11-10.0.26200-SP0

Python dependencies:
      sklearn: 1.9.1
          pip: 26.0.1
   setuptools: 80.10.2
        numpy: 2.5.1
        scipy: 1.18.0
       Cython: None
       pandas: 2.3.3
   matplotlib: None
       joblib: 1.5.3
threadpoolctl: 3.6.0
     narwhals: 2.23.0

Built with OpenMP: True

Interest in fixing the bug

Yes, I am ready for this

Activity

  1. added
    Needs Triage
    on Oct 10, 2026
  2. CheerathAniketh commented on Oct 10, 2026

    @CheerathAniketh

    The cause is in MLPRegressor.partial_fit: it's gated with @available_if(lambda est: est._check_solver), missing the call parentheses, so the check never runs (a bound method is always truthy). MLPClassifier uses est._check_solver().

    With the call added, hasattr(MLPRegressor(solver="lbfgs"), "partial_fit") is False, matching the classifier. I have a one-line fix plus a regression test (both estimators, all solvers) on my fork, with test_mlp.py passing locally: https://github.com/CheerathAniketh/scikit-learn/tree/fix-mlpregressor-partial-fit-lbfgs

    I have not opened a PR yet since the issue is still marked "Needs Triage". @cosimo17, you mentioned you're ready to fix this, so I'm happy to leave the PR to you, or to open mine once it's triaged, whichever you and the maintainers prefer.
    I reproduced the bug and verified the fix and tests locally.

  3. cakedev0 commented on Oct 12, 2026

    @cakedev0
    Member

    It looks like a valid & easy-to-fix issue. @cosimo17 feel free to fix it.

    To others: please don't open PRs when the issue author has expressed in fixing the bug.

  4. removed
    Needs Triage
    on Oct 12, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions