DOC Document that HGBT min_samples_leaf ignores sample_weight - #34838
DOC Document that HGBT min_samples_leaf ignores sample_weight#34838antoinebaker wants to merge 4 commits into
Conversation
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]>
Co-authored-by: Cursor <[email protected]>
| # 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. |
There was a problem hiding this comment.
@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.
|
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: 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
left a comment
There was a problem hiding this comment.
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 |
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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 |
There was a problem hiding this comment.
I would replace „unweighted sample count“ with „sample count based on number of data rows“. Similar in other places.
|
I opened #34885 which extends this PR to also include 2 related fixes to get the estimator check to pass:
|
|
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. |
Reference Issues/PRs
A small doc change for #34745.
What does this implement/fix? Explain your changes.
Follows the documentation approach from #34745 (comment):
min_samples_leaf(and in the histogram GB user guide), referring to thesample_weightglossary term for the repeated/weighted equivalence.Runcheck_sample_weight_equivalence_on_{dense,sparse}_datawithmin_samples_leaf=1and remove the corresponding XFAIL markers.AI usage disclosure
I used AI assistance for: