Skip to content

MNT Uses a less strict error message for n_features_in_ checks #18585

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 4 commits into from
Oct 14, 2020

Conversation

thomasjpfan
Copy link
Member

Reference Issues/PRs

Related to #18578 (comment)

What does this implement/fix? Explain your changes.

This PR updates the error message to not include the estimator name. This allows meta estimators to delegate to inner estimators and output a more generic error message.

Any other comments?

An alternative would be to catch the exception check its message and change the estimator name to the met estimator. This seems heavy handed.

CC @ogrisel

@jnothman jnothman changed the title MNT Uses a less strict error message for n_featuers_in_ checks MNT Uses a less strict error message for n_features_in_ checks Oct 12, 2020
@thomasjpfan
Copy link
Member Author

@NicolasHug Are you okay with this change?

@NicolasHug
Copy link
Member

I was thinking that having the estimator's name in the error message is useful precisely in the case of meta-estimators. No strong opinion anyway

@thomasjpfan
Copy link
Member Author

I was thinking that having the estimator's name in the error message is useful precisely in the case of meta-estimators. No strong opinion anyway

I am okay with this as well. Then we adjust the test:

msg = (f"X has 1 features, but {name} is expecting {X.shape[1]} "
"features as input")

to accept any name for the class name?

@NicolasHug
Copy link
Member

sure, this sounds good too

Copy link
Member

@NicolasHug NicolasHug left a comment

Choose a reason for hiding this comment

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

LGTM if green!

Copy link
Member

@ogrisel ogrisel left a comment

Choose a reason for hiding this comment

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

Ok let's do it this way for now and we can always be stricter later.

@ogrisel ogrisel merged commit 6b61d62 into scikit-learn:master Oct 14, 2020
amrcode pushed a commit to amrcode/scikit-learn that referenced this pull request Oct 19, 2020
jayzed82 pushed a commit to jayzed82/scikit-learn that referenced this pull request Oct 22, 2020
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.

4 participants