Skip to content

ENH Auto-requesting validation set for HistGradientBoosting* - #34957

Merged
StefanieSenger merged 65 commits into
scikit-learn:mainfrom
StefanieSenger:auto-request_X_val
Oct 6, 2026
Merged

StefanieSenger merged 65 commits into
scikit-learn:mainfrom
StefanieSenger:auto-request_X_val

Conversation

@StefanieSenger

@StefanieSenger StefanieSenger commented Sep 14, 2026 •

Copy link
Copy Markdown
Member

Reference Issues/PRs

towards #34901

What does this implement/fix? Explain your changes.

This adds auto-requests for X_val, y_val and sample_weight_val in HistGradientBoostingClassifier and HistGradientBoostingRegressor and tests.

AI usage disclosure

I used AI assistance for:

  • Research and understanding

adrinjalali and others added 30 commits February 27, 2025 16:22
@StefanieSenger
StefanieSenger marked this pull request as ready for review September 23, 2026 10:15
@StefanieSenger

StefanieSenger commented Sep 23, 2026 •

Copy link
Copy Markdown
Member Author

The CI failure comes from the link to :ref:metadata_routing_auto_request_user that I have used but doesn't exist here yet. It will pass after merging #35019.

@StefanieSenger StefanieSenger moved this from PR in progress to PR waiting for reviews in Labs Sep 23, 2026

@ogrisel ogrisel 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.

I think it would be good to showcase metadata routing of X_val and y_val in an example.

As far as I know was only done in past release release highlights.

I think we should have a dedicated example: for instance we could do a grid search of a pipeline with target encoder of categorical features + HistGradientBoosting on Ames housing.

We can either do that as part of this PR or in a follow-up PR.

y_val=y_val,
sample_weight_val=sample_weight_val,
)

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.

Shall we also expect UnsetMetadataPassedError to be raised if the user sets .set_fit_request(X_val=False) explicitly under a with config_context(enable_metadata_auto_requests=True) block?

I would expect so (I think).

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

I don't think so. UnsetMetadataPassedError is raised when a metadata request is set to None. If it's set explicitly by a user (True, False or an alias) it counts as a request set.

class UnsetMetadataPassedError(ValueError):
"""Exception class to raise if a metadata is passed which is not explicitly \
requested (metadata=True) or not requested (metadata=False).

@ogrisel ogrisel Sep 28, 2026 •

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.

What I mean is expand this test further to then call .set_fit_request(X_val=False) and issue the same pipe.fit call afterwards and check that UnsetMetadataPassedError in that case.

Would it makes sense?

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.

If I remember correctly, an explicit .set_fit_request(X_val=False) means that the router (pipeline) will not pass X_val to the consumer (HGBT) and no error is raised. The error is raised only when X_val=None.

@StefanieSenger

Copy link
Copy Markdown
Member Author

I think it would be good to showcase metadata routing of X_val and y_val in an example.

As far as I know was only done in past release release highlights.

I think we should have a dedicated example: for instance we could do a grid search of a pipeline with target encoder of >categorical features + HistGradientBoosting on Ames housing.

We can either do that as part of this PR or in a follow-up PR.

Yes, that's great idea. I'm happy to take care of this in a follow-up PR.

@ogrisel ogrisel 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. +1 for expanding the examples in a follow-up PR.

@cakedev0
cakedev0 self-requested a review September 28, 2026 14:22

@cakedev0 cakedev0 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.

I don't have a lot of context on metadata routing, but the changes seems very sound and my agent thinks too, so it feels enough to approve.

Just a tiny typo to fix first.


In a :class:`~pipeline.Pipeline`, `X_val` is transformed like `X` by default
(`transform_input`). Passing it through the pipeline requires metadata
routing; with auto-requests also enabled, `X_val`, `_val` and

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.

Typo: _val -> y_val

Suggested change
routing; with auto-requests also enabled, `X_val`, `_val` and
routing; with auto-requests also enabled, `X_val`, `y_val` and

routing; with auto-requests also enabled, `X_val`, `_val` and
`sample_weight_val` are requested automatically
(:func:`~sklearn.set_config`). See
:ref:`metadata_routing_auto_request_user`.

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.

This label is defined in #35019, so this will be a broken link (and a doc build warning) if this PR is merged first. #35019 looks like it will be merged soon, so I guess it's fine?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Yea, I think we better wait until its merged to avoid a red CI on main.

@antoinebaker antoinebaker 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 @StefanieSenger !

Could you ping me when the CI turns green (after the merge of #35019) ? I would like to proofread the rendered docs.

@StefanieSenger

Copy link
Copy Markdown
Member Author

Could you ping me when the CI turns green (after the merge of #35019) ? I would like to proofread the rendered docs.

Yes, I will do that. Thank you @antoinebaker!

@StefanieSenger

Copy link
Copy Markdown
Member Author

Could you ping me when the CI turns green (after the merge of #35019) ? I would like to proofread the rendered docs.

Yes, I will do that. Thank you @antoinebaker!

I've just updated this branch (after #35019 had been merged into main). You can now have a look at the rendered docs, @antoinebaker. :)

@antoinebaker

Copy link
Copy Markdown
Member

I checked the docs, LGMT !

@StefanieSenger

Copy link
Copy Markdown
Member Author

Great, thanks a lot @antoinebaker. I will then merge this one.

@StefanieSenger
StefanieSenger merged commit 9ac73fe into scikit-learn:main Oct 6, 2026
37 checks passed
@StefanieSenger
StefanieSenger deleted the auto-request_X_val branch October 6, 2026 07:18
@StefanieSenger StefanieSenger added the Metadata Routing all issues related to metadata routing, slep006, sample props label Oct 7, 2026
@StefanieSenger StefanieSenger added this to the 1.10 milestone Oct 15, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Metadata Routing all issues related to metadata routing, slep006, sample props module:ensemble module:utils

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants