10000 FIX solved legend issue in PDP by glemaitre · Pull Request #18713 · scikit-learn/scikit-learn · GitHub
[go: up one dir, main page]

Skip to content

FIX solved legend issue in PDP #18713

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

Merged
merged 6 commits into from
Nov 1, 2020
Merged

Conversation

glemaitre
Copy link
Member
@glemaitre glemaitre commented Oct 30, 2020

Fixing master
closes #18712

I am not sure why we did not catch these errors before merging:

PDP:

label could not be overwritten en plotting the PDP

  • Add regression tests
  • Check the rendering of all examples

CalibratedClassifierCV

This will be addressed in a separate pull-request

  • The example uses some private attributes.
Unexpected failing examples:
/home/circleci/project/examples/calibration/plot_calibration_multiclass.py failed leaving traceback:
Traceback (most recent call last):
  File "/home/circleci/project/examples/calibration/plot_calibration_multiclass.py", line 144, in <module>
    zip(calibrated_classifier.calibrators_, p.T)]).T
AttributeError: '_CalibratedClassifier' object has no attribute 'calibrators_'

@glemaitre glemaitre changed the title FIX overwrite PDP label if provided FIX solve issue introduced in PDP and CalibratedClassifierCV Oct 30, 2020
label = None if self.kind == "average" else "average"
# do not modify the `line_kw` in place since it might be reuse for
# each feature for which the partial dependence is requested
line_kw = deepcopy(line_kw)
Copy link
Member

Choose a reason for hiding this comment

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

Do you think this is cleaner:

default_line_kw = {'label': None if self.kind == "average" else "average"}
line_kw = {**default_line_kw, **line_kw}

And then update the signature of _plot_average_dependence to only accept line_kw.

This would lower the number of arguments for _plot_average_dependence as well.

Copy link
Member

Choose a reason for hiding this comment

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

Sounds like a good suggestion.

Copy link
Member Author

Choose a reason for hiding this comment

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

Nice

Copy link
Member
@ogrisel ogrisel left a comment

Choose a reason for hiding this comment

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

Once @thomasjpfan suggestion has been taken into account, +1 for merging the part on PDP.

For the part on the calibrators, maybe we could introduce a property with a deprecation warning to provide some backward compat.

@@ -141,7 +141,7 @@ class of an instance (red: class 1, green: class 2, blue: class 3).
calibrated_classifier = sig_clf.calibrated_classifiers_[0]
prediction = np.vstack([calibrator.predict(this_p)
for calibrator, this_p in
zip(calibrated_classifier.calibrators_, p.T)]).T
zip(calibrated_classifier.calibrators, p.T)]).T
Copy link
Member

Choose a reason for hiding this comment

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

hum.. that's bad because we changed something that could be argue to be part of the public API since 0.23. We took care of it for calibrated_classifiers_ but not for this nested attribute...

@glemaitre would you mind splitting this PR in two to merge them independently?

Copy link
Member

Choose a reason for hiding this comment

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

But even if we add the backward compat we should indeed also update the example to avoid triggering the FutureWarning.

Copy link
Member Author

Choose a reason for hiding this comment

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

I will do that.

@glemaitre glemaitre changed the title FIX solve issue introduced in PDP and CalibratedClassifierCV FIX solved legend issue in PDP Oct 30, 2020
@glemaitre
Copy link
Member Author

OK We should be OK now for the PDP part.

@glemaitre
Copy link
Member Author

I will open a new issue for the calibration

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.

LGTM

@ogrisel ogrisel merged commit 60945b4 into scikit-learn:master Nov 1, 2020
@ogrisel
Copy link
Member
ogrisel commented Nov 1, 2020

Thanks @glemaitre.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Issue with CircleCI and documentation
3 participants
0