Skip to content

DOC correct error message when checking response values of an estimator - #33084

Closed
qbarthelemy wants to merge 2 commits into
scikit-learn:mainfrom
qbarthelemy:error_response_values
Closed

qbarthelemy wants to merge 2 commits into
scikit-learn:mainfrom
qbarthelemy:error_response_values

Conversation

@qbarthelemy

@qbarthelemy qbarthelemy commented Jan 14, 2026 •

Copy link
Copy Markdown
Contributor

Reference Issues/PRs

What does this implement/fix? Explain your changes.

Current function that checks response values of an estimator
(_get_response_values in scikit-learn/sklearn/utils/_response.py)
assumes that if the estimator is not a classifier or an outlier detector, then it is a regressor.

In the latter case, if it doesn't find the predict function,
it raises an error stating that the estimator is a regressor: ValueError: ... Got a regressor....

However, the estimator might be something other than a regressor.

For example, it can be a classification Pipeline with a MRO issue, see NeuroTechX/moabb#815

Many other GitHub repositories have reported this ambiguous error:
dreamquark-ai/tabnet#584
rasbt/mlxtend#1129
dmlc/xgboost#11284
mljar/mljar-supervised#640
csinva/imodels#221
etc

The goal of this pull-request is to correct the message by making it clearer,
specifically by no longer assuming that it is a regressor.

AI usage disclosure

I did not use AI assistance.

Any other comments?

@AnneBeyer

Copy link
Copy Markdown
Member

Thank you for reporting this @qbarthelemy!

We noticed something possibly related in #33015 (comment), where estimator can also be a clusterer.

Instead of proposing a solution directly, it would be better to open an issue first, so that we can discuss if and how this problem can be approached best.

Regarding this PR:
Your suggested changes do not only change the docs (as the title suggests), but also the behavior of the code, so the corresponding tests need to be adjusted/extended as well. But as said above, it would be best to gather feedback from maintainers on your proposed solution in an issue first, before putting in the work of fixing it.

@lucyleeow

Copy link
Copy Markdown
Member

Agreed, let's discuss in an issue first.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants