Skip to content

Improve SimpleImputer error message for incompatible fill_value types #30828

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
May 6, 2025

Conversation

Waknis
Copy link
Contributor

@Waknis Waknis commented Feb 14, 2025

Reference Issues/PRs

Fixes #29381

What does this implement/fix? Explain your changes.

This PR updates the error message in SimpleImputer when fill_value cannot be cast to the input data type.

  • The new message explicitly suggests using a NumPy scalar (e.g., np.uint8(0)) if the data type is np.uint8.
  • This change improves clarity for users encountering the issue.
  • No functional behavior was modified—this is purely an error message enhancement.

Any other comments?

  • This change was discussed in the related issue and aligns with the suggested fix.
  • Let me know if any refinements are needed!

Copy link

github-actions bot commented Feb 14, 2025

✔️ Linting Passed

All linting checks passed. Your pull request is in excellent shape! ☀️

Generated for commit: 202686a. Link to the linter CI: here

Copy link
Member

@adrinjalali adrinjalali left a comment

Choose a reason for hiding this comment

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

Nit on the wording, otherwise LGTM.

Co-authored-by: Adrin Jalali <adrin.jalali@gmail.com>
@adrinjalali adrinjalali merged commit 7cf4e42 into scikit-learn:main May 6, 2025
36 checks passed
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.

SimpleImputer's fill_value validation seems too strict
2 participants