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

Skip to content

DOC Document that HGBT min_samples_leaf ignores sample_weight - #34838

Open
antoinebaker wants to merge 4 commits into
scikit-learn:mainfrom
antoinebaker:doc/hgb-min-samples-leaf-sample-weight
Open

DOC Document that HGBT min_samples_leaf ignores sample_weight#34838
antoinebaker wants to merge 4 commits into
scikit-learn:mainfrom
antoinebaker:doc/hgb-min-samples-leaf-sample-weight

Conversation

@antoinebaker

@antoinebaker antoinebaker commented Aug 28, 2026

Copy link
Copy Markdown
Contributor

Reference Issues/PRs

A small doc change for #34745.

What does this implement/fix? Explain your changes.

Follows the documentation approach from #34745 (comment):

  • Document the limitation on min_samples_leaf (and in the histogram GB user guide), referring to the sample_weight glossary term for the repeated/weighted equivalence.
  • Run check_sample_weight_equivalence_on_{dense,sparse}_data with min_samples_leaf=1 and remove the corresponding XFAIL markers.

AI usage disclosure

I used AI assistance for:

  • Code generation
  • Documentation

antoinebaker and others added 2 commits August 28, 2026 15:15
min_samples_leaf is applied to unweighted sample counts, so the
sample-weight / sample-repetition equivalence only holds when
min_samples_leaf=1. Document this limitation and run the common
equivalence checks in that configuration.

Co-authored-by: Cursor <[email protected]>
@antoinebaker
antoinebaker marked this pull request as draft August 28, 2026 14:15
@antoinebaker
antoinebaker marked this pull request as ready for review August 28, 2026 15:07
@antoinebaker antoinebaker moved this to PR waiting for reviews in Labs Sep 1, 2026
@antoinebaker antoinebaker added this to Labs Sep 1, 2026
Comment thread doc/whats_new/upcoming_changes/sklearn.ensemble/34838.enhancement.rst Outdated
# min_samples_leaf is applied to unweighted sample counts, so the
# sample-weight / sample-repetition equivalence only holds when
# min_samples_leaf=1. max_depth=1 is also required on the tiny datasets
# used by these checks; deeper trees can still diverge. See issue #34745.

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.

@antoinebaker any idea of the root cause of the failure on deeper trees? Would adding a bit of l2 regularization help?

I would rather not remove the XFAIL marker as long as we do not fully understand if there is a remaining bug with deeper trees.

If you want, feel free to revert the XFAIL related change and the max_depth=1 parametrization while keeping the min_samples_leaf=1 parametrization with the above comment that justifies it.

Then in the XFAIL entries, link to a #34745 with some updated info or even a new dedicated issue to investigate the problem with deeper trees.

@ogrisel

ogrisel commented Sep 4, 2026

Copy link
Copy Markdown
Member

I iterated a bit with cursor and it seems possible to fix the remaining bug by preventing splits that would result in creating zero weight leaves:

ogrisel#27

The code change seems simple enough and should not negatively impact performance too much. WDYT?

@antoinebaker

antoinebaker commented Sep 4, 2026

Copy link
Copy Markdown
Contributor Author

The code change seems simple enough and should not negatively impact performance too much. WDYT?

Yep sounds good! Locally the common check indeed passes if we use nonzero sample weight, so I think your PR should indeed fix the issue.

Could you open your PR in sklearn and assign me as reviewer ?

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

THX for this PR. This is a welcome improvement of the documentation.

HistGradientBoostingClassifier: {
# TODO: replace by a statistical test, see meta-issue #16298
# TODO: use min_samples_leaf=1 and exclude zero-weight samples in tree grower
# see issue #34745 and https://github.com/ogrisel/scikit-learn/pull/27

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 like links to github in tests and I certainly don’t like links to „foreign“ repos. I prefere a short self containt comment.

Is there a github issue and a minimal reproducible example? I think we should stick to our own standards.

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 have created a new PR in #34885 with extra tests and working config for the existing sample weight equivalence check.

than a few hundred samples, it is recommended to lower this value
since only very shallow trees would be built.

This constraint is applied to the unweighted sample count, not the

@lorentzenchr lorentzenchr Sep 10, 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.

I would replace „unweighted sample count“ with „sample count based on number of data rows“. Similar in other places.

@ogrisel

ogrisel commented Sep 10, 2026

Copy link
Copy Markdown
Member

I opened #34885 which extends this PR to also include 2 related fixes to get the estimator check to pass:

  • using a bit of l2 reg in addition to min_samples_leaf=1;
  • make sure we don't selects different splits based on small random rounding errors.

@lorentzenchr

Copy link
Copy Markdown
Member

This is a simple doc improvement. Why not merge it and put additional work in separate PRs? E.g. I don’t need a test here.

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