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
[MRG] Expose interpolation thresholds as public fitted attribute of IsotonicRegression #16289
[MRG] Expose interpolation thresholds as public fitted attribute of IsotonicRegression #16289
Conversation
why exposing more public attribute helps you in other languages? |
I want to save interpolation points ( But because |
as you will need to serialize the object manually I would suggest you
deal with it in your code.
These private attributes are not guaranteed to change but rather
unlikely. If you want you can
add a test that will break if we change these.
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
While I agree that in general we should not expose every thing as public attribute just for the purpose of making it easier for people to write model exporters, I am not opposed to exposing those attributes for this particular case, for model inspection purpose. There are only two attributes, this class has no other fitted attributes and those 2 arrays could be meaningfully plotted to graphically explain what the model does.
Actually this example (examples/plot_isotonic_regression.py) would really benefit to be updated to add a side plot of the X_threshods_
vs y_thresholds_
for education purpose.
But if we expose new public attributes we need more tests for the presence of those attributes and their values (e.g. that both arrays have the same length, that there values are increasing, in the range of the training data and that the length is not larger than the training set). This could be a good opportunity to check that the de-duplication code works as expected on some toy training sets with just a few well chosen samples that would illustrate some extreme cases.
I am ok with that if we make it part of educational material in an example.
+1 to rename as suggested too
… |
Thank you for following. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@kishimoto-banana are you also interested in updating the example as described in #16289 (review)? or do you want someone else to take over this PR to finish that part?
Co-Authored-By: Olivier Grisel <olivier.grisel@ensta.org>
@ogrisel Thank you for your comments. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM :)
I cannot access the codecov report at the moment. I get HTTP error 500 whenever I click on the reports. |
codecov was broken when uploading the coverage data of some of the jobs: Hence the decrease in coverage. |
Alright, code coverage is now happy. |
Thanks @thomasjpfan for fixing the PR. Would you like to review it? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks @kishimoto-banana , looks good.
In the prediction function plot it'd be good to also plot the extrapolation lines, i.e. beyond X.min() and X.max(). If it makes the code less clear, a simple sentence could be enough:
Beyond the limits of the training data (i.e. before X.min() and after X.max()), the prediction corresponds to pred(X.min()) and pred(X.max()) respectively.
@ogrisel I'm not quite sure about keeping backward compat here?
Co-Authored-By: Nicolas Hug <contact@nicolas-hug.com>
Co-Authored-By: Nicolas Hug <contact@nicolas-hug.com>
Co-authored-by: Nicolas Hug <contact@nicolas-hug.com>
I believe I have addressed all the pending review comments @NicolasHug @thomasjpfan. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks both, some minor comments but LGTM anyway
Co-authored-by: Nicolas Hug <contact@nicolas-hug.com>
…sotonicRegression (scikit-learn#16289) Co-authored-by: Olivier Grisel <olivier.grisel@ensta.org> Co-authored-by: Thomas J Fan <thomasjpfan@gmail.com> Co-authored-by: Nicolas Hug <contact@nicolas-hug.com>
…sotonicRegression (scikit-learn#16289) Co-authored-by: Olivier Grisel <olivier.grisel@ensta.org> Co-authored-by: Thomas J Fan <thomasjpfan@gmail.com> Co-authored-by: Nicolas Hug <contact@nicolas-hug.com>
I want to reconstruct fitted stepwise interpolation function of isotonic regression in other programming languages (Scala, Go, ...).
Therefore, I want to get interpolation points (input to function
f_
).However, interpolation points (
_necessary_X_
,_necessary_y_
) are internal variable of IsotonicRegression class according to PEP8 (leading underscores).This PR changes interpolation points to attributes of IsotonicRegression class.