Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[AIR] Add KBinsDiscretizer #28389

Merged
merged 7 commits into from
Sep 16, 2022
Merged

Conversation

Yard1
Copy link
Member

@Yard1 Yard1 commented Sep 8, 2022

Signed-off-by: Antoni Baum [email protected]

Why are these changes needed?

K-Bins discretization is a common preprocessing step. This PR adds two new preprocessors - CustomKBinsDiscretizer and UniformKBinsDiscretizer. The former uses user-defined bin edges and in the latter, the user provides a desired number of bins and uniform-width bins are created automatically. Both of those preprocessors are essentially thin wrappers around pandas.cut.

In the future, a quantile-based K-Bins discretizer should be added, as that is also commonly used. It is more complex to implement, though. For the time being, users can calculate the quantiles themselves and pass them to CustomKBinsDiscretizer.

Related issue number

Closes #28301

Checks

  • I've signed off every commit(by using the -s flag, i.e., git commit -s) in this PR.
  • I've run scripts/format.sh to lint the changes in this PR.
  • I've included any doc changes needed for https://docs.ray.io/en/master/.
  • I've made sure the tests are passing. Note that there might be a few flaky tests, see the recent failures at https://flakey-tests.ray.io/
  • Testing Strategy
    • Unit tests
    • Release tests
    • This PR is not tested :(

Signed-off-by: Antoni Baum <[email protected]>
Signed-off-by: Antoni Baum <[email protected]>
@Yard1 Yard1 added this to the Ray AIR milestone Sep 8, 2022
@Yard1 Yard1 requested review from jjyao, jianoaix, c21 and a team as code owners September 8, 2022 22:30
@Yard1 Yard1 marked this pull request as draft September 8, 2022 22:35
Signed-off-by: Antoni Baum <[email protected]>
Signed-off-by: Antoni Baum <[email protected]>
@Yard1 Yard1 marked this pull request as ready for review September 8, 2022 22:41
@richardliaw richardliaw removed their request for review September 9, 2022 01:12
@@ -74,6 +74,15 @@ Feature Scalers
.. autoclass:: ray.data.preprocessors.StandardScaler
:show-inheritance:

K-Bins Discretizers
Copy link
Member

Choose a reason for hiding this comment

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

Would a more-general Discretizers be better? I see sklearn does something similar in their user guide https://scikit-learn.org/stable/modules/preprocessing.html#discretization

Copy link
Member Author

Choose a reason for hiding this comment

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

Sure, makes sense!

Copy link
Member

@bveeramani bveeramani left a comment

Choose a reason for hiding this comment

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

Overall LGTM. Left some minor suggestions and questions.

Could you see if you can reproduce my inconsistent output? https://github.com/ray-project/ray/pull/28389/files#r967751046

@richardliaw richardliaw merged commit e63b405 into ray-project:master Sep 16, 2022
PaulFenton pushed a commit to PaulFenton/ray that referenced this pull request Sep 19, 2022
Co-authored-by: Balaji Veeramani <[email protected]>
Signed-off-by: PaulFenton <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[AIR] K-Bins discretizer
5 participants