Repository navigation
[Data] Fix OneHotEncoder max_categories to use global top-k instead of per-partition - #60790
Merged
alexeykudinkin merged 6 commits intoFeb 10, 2026
Merged
Conversation
Signed-off-by: xgui <[email protected]>
Signed-off-by: xgui <[email protected]>
Contributor
There was a problem hiding this comment.
Code Review
This pull request fixes a bug in how top-k categories are computed when max_categories is used in encoders like OneHotEncoder. The previous implementation applied the top-k logic per partition, leading to incorrect global top-k results. The fix correctly aggregates value counts across all partitions before determining the top-k categories. A regression test is added to verify this fix. The changes look good and address the issue effectively. I have one minor suggestion to improve code clarity.
xinyuangui2
marked this pull request as ready for review
February 9, 2026 17:46
alexeykudinkin
approved these changes
Feb 10, 2026
ans9868
pushed a commit
to ans9868/ray
that referenced
this pull request
Feb 18, 2026
…f per-partition (ray-project#60790) ## Summary - Fix `compute_unique_value_indices` to aggregate value counts globally across all partitions before applying `max_categories` top-k selection. Previously, top-k was applied per-partition and then unioned, which could miss categories that appear moderately across many partitions (e.g. a value with count 3 in two partitions has global count 6 but would be excluded if each partition only keeps its top-2). - Add docstring for `compute_unique_value_indices` documenting the global aggregation behavior and all parameters. --------- Signed-off-by: xgui <[email protected]> Signed-off-by: Adel Nour <[email protected]>
Aydin-ab
pushed a commit
to kunling-anyscale/ray
that referenced
this pull request
Feb 20, 2026
…f per-partition (ray-project#60790) ## Summary - Fix `compute_unique_value_indices` to aggregate value counts globally across all partitions before applying `max_categories` top-k selection. Previously, top-k was applied per-partition and then unioned, which could miss categories that appear moderately across many partitions (e.g. a value with count 3 in two partitions has global count 6 but would be excluded if each partition only keeps its top-2). - Add docstring for `compute_unique_value_indices` documenting the global aggregation behavior and all parameters. --------- Signed-off-by: xgui <[email protected]>
4 tasks done
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
compute_unique_value_indicesto aggregate value counts globally across all partitionsbefore applying
max_categoriestop-k selection. Previously, top-k was appliedper-partition and then unioned, which could miss categories that appear moderately across
many partitions (e.g. a value with count 3 in two partitions has global count 6 but would be
excluded if each partition only keeps its top-2).
compute_unique_value_indicesdocumenting the global aggregationbehavior and all parameters.