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

ENH Allow isotonic reg 2d input with 1 feature (GH15012) #17379

Conversation

fujiaxiang
Copy link
Contributor

Reference Issues/PRs

Fixes #15012
Fixes #17333

What does this implement/fix? Explain your changes.

This PR allows IsotonicRegression to accept 2D inputs in its fit, predict and transform methods.

@fujiaxiang
Copy link
Contributor Author

This PR closes 2 issues as far as I know.

Because #17333 is the direct cause of #15012, I did not mention #17333 in my comments. Hope that's the right thing to do.

@fujiaxiang
Copy link
Contributor Author

btw I tested the fix locally, it does indeed fix #17333. Again because it's essentially the same issue, I did not add any tests specifically testing IsotonicRegression used in an ensemble.

If that test should be added, just let me know!
Cheers!

@fujiaxiang fujiaxiang changed the title [WIP] Allow isotonic reg 2d input with 1 feature (GH15012) [MRG] Allow isotonic reg 2d input with 1 feature (GH15012) May 29, 2020
Copy link
Member

@thomasjpfan thomasjpfan left a comment

Choose a reason for hiding this comment

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

Thank you @fujiaxiang !

sklearn/isotonic.py Outdated Show resolved Hide resolved
sklearn/isotonic.py Outdated Show resolved Hide resolved
sklearn/tests/test_isotonic.py Outdated Show resolved Hide resolved
sklearn/tests/test_isotonic.py Outdated Show resolved Hide resolved
sklearn/tests/test_isotonic.py Outdated Show resolved Hide resolved
sklearn/tests/test_isotonic.py Outdated Show resolved Hide resolved
Copy link
Member

@NicolasHug NicolasHug left a comment

Choose a reason for hiding this comment

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

Thanks @fujiaxiang , a few comments but looks good in general!

doc/whats_new/v0.24.rst Outdated Show resolved Hide resolved
sklearn/isotonic.py Outdated Show resolved Hide resolved
sklearn/tests/test_isotonic.py Outdated Show resolved Hide resolved
sklearn/tests/test_isotonic.py Outdated Show resolved Hide resolved
fujiaxiang and others added 8 commits June 2, 2020 10:49
change flatten to reshape(-1)

Co-authored-by: Thomas J. Fan <thomasjpfan@gmail.com>
change flatten to reshape(-1)

Co-authored-by: Thomas J. Fan <thomasjpfan@gmail.com>
change array(list(range(10))) to arange(10)

Co-authored-by: Thomas J. Fan <thomasjpfan@gmail.com>
simplify test input

Co-authored-by: Thomas J. Fan <thomasjpfan@gmail.com>
simplify test input

Co-authored-by: Thomas J. Fan <thomasjpfan@gmail.com>
simplify code

Co-authored-by: Thomas J. Fan <thomasjpfan@gmail.com>
change assert_array_equal to assert_allclose

Co-authored-by: Nicolas Hug <contact@nicolas-hug.com>
@fujiaxiang
Copy link
Contributor Author

@thomasjpfan @NicolasHug thanks for reviewing.
Have made the changes accordingly. Can you review again?

Copy link
Member

@thomasjpfan thomasjpfan left a comment

Choose a reason for hiding this comment

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

Minor comments, otherwise LGTM

doc/whats_new/v0.24.rst Outdated Show resolved Hide resolved
sklearn/tests/test_isotonic.py Outdated Show resolved Hide resolved
fujiaxiang and others added 2 commits June 2, 2020 22:57
reformat whatsnew entry

Co-authored-by: Thomas J. Fan <thomasjpfan@gmail.com>
clean up comment in test case

Co-authored-by: Thomas J. Fan <thomasjpfan@gmail.com>
@fujiaxiang
Copy link
Contributor Author

@thomasjpfan committed the suggested changes. thanks :)

Copy link
Member

@thomasjpfan thomasjpfan left a comment

Choose a reason for hiding this comment

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

I have already approved this. This needs a second approval to get merged.

@fujiaxiang
Copy link
Contributor Author

got it. will wait for @NicolasHug to review again

@fujiaxiang
Copy link
Contributor Author

ping

@fujiaxiang
Copy link
Contributor Author

ping

@fujiaxiang
Copy link
Contributor Author

hi @NicolasHug could you review again?

Copy link
Member

@NicolasHug NicolasHug left a comment

Choose a reason for hiding this comment

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

thanks for your patience @fujiaxiang

doc/whats_new/v0.24.rst Outdated Show resolved Hide resolved
sklearn/isotonic.py Outdated Show resolved Hide resolved
sklearn/isotonic.py Outdated Show resolved Hide resolved
sklearn/isotonic.py Outdated Show resolved Hide resolved
sklearn/isotonic.py Outdated Show resolved Hide resolved
@fujiaxiang
Copy link
Contributor Author

@NicolasHug thanks for the comments and suggestions. Have made the adjustments. Can you review again?

@fujiaxiang
Copy link
Contributor Author

hi @NicolasHug can you review again?


y_pred1 = iso_reg.predict(X)
y_pred2 = iso_reg_2d.predict(X_2d)
assert_allclose(y_pred1, y_pred2)
Copy link
Member

Choose a reason for hiding this comment

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

Please also check that the estimator attributes match in shape. Thanks

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Hi @jnothman, thanks for review. Are you referring to the _necessary_X_ and _necessary_y_ attributes? I have added checking for these two attributes. If it's something else, can you give a bit more details what you mean?

Copy link
Member

Choose a reason for hiding this comment

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

Sorry, I meant the public attributes X_min_, X_max_, etc.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

hi @jnothman, sorry for the late reply. I have added the checks as requested. Could you review again?

@fujiaxiang fujiaxiang requested a review from jnothman June 25, 2020 08:32
…w_2darray_with_1_feature

# Conflicts:
#	doc/whats_new/v0.24.rst
#	sklearn/tests/test_isotonic.py
Copy link
Member

@jnothman jnothman left a comment

Choose a reason for hiding this comment

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

Thank you @fujiaxiang

@jnothman jnothman changed the title [MRG] Allow isotonic reg 2d input with 1 feature (GH15012) ENH Allow isotonic reg 2d input with 1 feature (GH15012) Jul 6, 2020
@jnothman jnothman merged commit 4e6a6e2 into scikit-learn:master Jul 6, 2020
@fujiaxiang fujiaxiang deleted the isotonic_reg_allow_2darray_with_1_feature branch July 7, 2020 01:59
glemaitre pushed a commit to glemaitre/scikit-learn that referenced this pull request Jul 17, 2020
jayzed82 pushed a commit to jayzed82/scikit-learn that referenced this pull request Oct 22, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
4 participants