Repository navigation
Conversation
Only split the sample indices, fit the bin mapper on the training samples and split the binned data. This avoids a float64 copy of X. Co-Authored-By: Claude Opus 5.5 <[email protected]>
Co-Authored-By: Claude Opus 5.5 <[email protected]>
Co-Authored-By: Claude Opus 5.5 <[email protected]>
Co-Authored-By: Claude Opus 5.5 <[email protected]>
|
FWIW it's quite nice to have test infrastructure allowing to make assertions about peak memory usage... but also somewhat tricky. Something like this works if all libraries involved use Python's memory allocators. NumPy does, at least, not sure about other sklearn dependencies though: https://github.com/itamarst/polars/blob/2cb081d9fe2e306732585dafb090f503fb7dc56e/py-polars/tests/unit/conftest.py#L146-L176 |
|
As discussed IRL, I am wondering if such an optimization will be easy to adapt to a potential feature refactoring of the early stopping feature based on callbacks. I haven't thought it through yet. |
I'll put it back to draft while I haven't investigated that. I plan to dive a bit in callbacks at some point, I'll do it at this time. |
Reference Issues/PRs
Third part of the split of #35162. Independent of the other parts, based on main.
What does this implement/fix? Explain your changes.
With early stopping on the internal validation split, HGB used to split X, then bin both parts. Now it splits the sample indices, bins X once (the bin mapper is fitted on the training samples only, via a new
sample_indicesparameter of_BinMapper.fit) and then splits the binned data.This avoids a float64 copy of X: the binned data is 8 times smaller. This is very beneficial when using HGB under
*SearchCVas it reduces a lot the risk of OOM when usingn_jobs=-1(which is very often the best option for speed, but is expensive in memory).AI usage disclosure
I used AI assistance for:
Benchmarks
HGB fit, early stopping with the internal validation split, 20 iterations: