Skip to content

Param validation for Dictvectorizer #23820

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
Jul 6, 2022

Conversation

SangamSwadiK
Copy link
Contributor

Reference Issues/PRs

Issue: #23462 (make estimators use _validate_params)

What does this implement/fix? Explain your changes.

Adds parameter validation to DictVectorizer.

Any other comments?

Added #Todo for parameter dtype

@jeremiedbb jeremiedbb added No Changelog Needed Validation related to input validation labels Jul 4, 2022
Copy link
Member

@jeremiedbb jeremiedbb left a comment

Choose a reason for hiding this comment

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

Thanks for the PR @SangamSwadiK. You forgot to remove the estimator from the common test blacklist :)

Please also call _validate_params in fit_transform.

@@ -97,6 +97,13 @@ class DictVectorizer(TransformerMixin, BaseEstimator):
array([[0., 0., 4.]])
"""

_parameter_constraints = {
"dtype": [type], # TODO: TypeOptions constraint,
Copy link
Member

@jeremiedbb jeremiedbb Jul 6, 2022

Choose a reason for hiding this comment

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

When any dtype is valid, we'd rather delegate validation to numpy since dtype can be exressed in many different ways, as discussed in #23579

Suggested change
"dtype": [type], # TODO: TypeOptions constraint,
"dtype": "no_validation" # validation delegated to numpy

Copy link
Member

@jeremiedbb jeremiedbb left a comment

Choose a reason for hiding this comment

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

LGTM

@jeremiedbb
Copy link
Member

@Micky774 does this PR has your +1 now ?

@Micky774
Copy link
Contributor

Micky774 commented Jul 6, 2022

@Micky774 does this PR has your +1 now ?

Yes, looks good now, +1.

@jeremiedbb
Copy link
Member

Merging. Thanks @SangamSwadiK for the PR and @Micky774 for the review.

@jeremiedbb jeremiedbb merged commit 5a850eb into scikit-learn:main Jul 6, 2022
Harsh14901 pushed a commit to Harsh14901/scikit-learn that referenced this pull request Jul 6, 2022
ogrisel pushed a commit to ogrisel/scikit-learn that referenced this pull request Jul 11, 2022
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