Thanks to visit codestin.com
Credit goes to github.com

Skip to content

MNT Param validation: Make it possible to mark a constraint as hidden #23558

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 8 commits into from
Jun 13, 2022

Conversation

jeremiedbb
Copy link
Member

Some parameters accepts types as an unofficial way. For instance criterion in trees can be an instance of Criterion but that's not documented and not meant to be documented.

For these, we don't want the error message of the validation of this parameter to say that this unofficial type is valid. Hence this PR proposes to make it possible to mark a constraint as internal such that it's not shown in the message.

@@ -640,7 +640,7 @@ class LinearRegression(MultiOutputMixin, RegressorMixin, LinearModel):

_parameter_constraints = {
"fit_intercept": [bool],
"normalize": [StrOptions({"deprecated"}, internal={"deprecated"}), bool],
"normalize": [Internal(StrOptions({"deprecated"})), bool],
Copy link
Member

Choose a reason for hiding this comment

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

For developer ergonomics, Internal looks very similar to Interval. (At a glance, I thought it was Interval). What do you think of renaming Interval to Range?

Copy link
Member Author

Choose a reason for hiding this comment

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

I kind of prefer Interval, and range being a python keyword I think it could also bring confusion. Maybe we can change Internal instead. What do you think about Private or Hidden ?

Copy link
Member

Choose a reason for hiding this comment

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

I am +1 for Hidden

Copy link
Member

@glemaitre glemaitre left a comment

Choose a reason for hiding this comment

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

I am fine with the rest of the PR.

@glemaitre glemaitre changed the title MNT Param validation: Make it possible to mark a constraint as internal MNT Param validation: Make it possible to mark a constraint as hideen Jun 9, 2022
Copy link
Member

@glemaitre glemaitre left a comment

Choose a reason for hiding this comment

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

LGTM

@glemaitre glemaitre changed the title MNT Param validation: Make it possible to mark a constraint as hideen MNT Param validation: Make it possible to mark a constraint as hidden Jun 9, 2022
@@ -273,7 +274,8 @@ def _tolerance(X, tol):
"sample_weight": ["array-like", None],
"init": [StrOptions({"k-means++", "random"}), callable, "array-like"],
"n_init": [
StrOptions({"auto", "warn"}, internal={"warn"}),
StrOptions({"auto"}),
Hidden(StrOptions({"warn"})),
Copy link
Member

Choose a reason for hiding this comment

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

The alternative is StrOptions({"warn"}, hidden=True), but then we would need _InstancesOf "public", to do InstancesOf(Criterion, hidden=True). Also all the other constraints will have to be "public" to be configured to hide.

With that in mind, I'm okay with the PR as is.

Copy link
Member

@thomasjpfan thomasjpfan left a comment

Choose a reason for hiding this comment

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

LGTM

@glemaitre This PR changed a little bit since your approval. Do you want to take another look?

@glemaitre glemaitre merged commit de659b9 into scikit-learn:main Jun 13, 2022
@glemaitre
Copy link
Member

Still LGTM. Merging.

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