Skip to content

Limit interaction_cst to list/tuple of lists/tuples/sets in HistGradientBoosting* - #24915

Merged
jeremiedbb merged 3 commits into
scikit-learn:mainfrom
betatim:fix-interaction_cst-parameter-validation
Nov 22, 2022
Merged

jeremiedbb merged 3 commits into
scikit-learn:mainfrom
betatim:fix-interaction_cst-parameter-validation

Conversation

@betatim

@betatim betatim commented Nov 14, 2022

Copy link
Copy Markdown
Member

Instead of allowing arbitrary "iterable of iterables" the interaction_cst parameter is constrained to be a sequence (list, tuple) of list/tuple/set of integers.

Reference Issues/PRs

Closes #24899

Any other comments?

It feels more "pythonic" (but I hate that as an argument to justify coding choices) to try and iterate over the input and convert it into a list of sets. Instead of trying to nail down the exact allowed types of inputs. What we care about here is that the user's input can be turned into a list of sets of integers.

The docstring says "sequence of tuples/list of ints", this was the best formulation I could find. Even though this "sequence" isn't meant to be the Python type collections.abc.Sequence. I think the chance of a user misunderstanding it (and sending their strict typing lawyers after us) is low.

I don't really like that we limit to list and tuple in the parameter validation, but I can't think of a better way. My preferred option would probably be to write collections.abc.Sequence in _parameter_constraints combined with the later checks in the class.

@betatim

betatim commented Nov 14, 2022

Copy link
Copy Markdown
Member Author

This is ready for review

Instead of allowing arbitrary "iterable of iterables" the
itneraction_cst parameter is constrained to be a sequence
(list, tuple) of list/tuple/set of integers.
@betatim
betatim force-pushed the fix-interaction_cst-parameter-validation branch from 3509e84 to 9006201 Compare November 17, 2022 13:48
@betatim

betatim commented Nov 22, 2022 •

Copy link
Copy Markdown
Member Author

If you have time, a brief review would be welcome @lorentzenchr

@lorentzenchr lorentzenchr left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

LGTM Better to start conservative with this new feature.

@lorentzenchr lorentzenchr added this to the 1.2 milestone Nov 22, 2022
@lorentzenchr lorentzenchr added Quick Review For PRs that are quick to review Waiting for Second Reviewer First reviewer is done, need a second one! labels Nov 22, 2022

@jeremiedbb jeremiedbb left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

LGTM

@jeremiedbb
jeremiedbb merged commit 73642d4 into scikit-learn:main Nov 22, 2022
@jeremiedbb

Copy link
Copy Markdown
Member

Thanks @betatim

@betatim
betatim deleted the fix-interaction_cst-parameter-validation branch November 22, 2022 15:45
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

module:ensemble No Changelog Needed Quick Review For PRs that are quick to review Waiting for Second Reviewer First reviewer is done, need a second one!

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Strange parameter validation for interaction constraints in HistGradientBoosting*

3 participants