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

DOC add examples to two docstrings for calibration #28742

Open
wants to merge 7 commits into
base: main
Choose a base branch
from

Conversation

mingness
Copy link

@mingness mingness commented Apr 1, 2024

Reference Issues/PRs

Contributes towards issue #26927

What does this implement/fix? Explain your changes.

Examples of calibration added to docstrings in sklearn/calibration.py

Any other comments?

Copy link

github-actions bot commented Apr 1, 2024

✔️ Linting Passed

All linting checks passed. Your pull request is in excellent shape! ☀️

Generated for commit: 09cb1b3. Link to the linter CI: here

@betatim
Copy link
Member

betatim commented Apr 2, 2024

Thanks for working on this! This looks good, I'd just move where it is in the docstrings.

Lets see what happens to the CI run after you make those changes. I guess these aren't real failures so hopefully they will go away on the next re-run. Otherwise we need to investigate a bit.

@mingness
Copy link
Author

mingness commented Apr 2, 2024

I've moved the links to the examples as per the example you provided, many thanks.

sklearn/calibration.py Outdated Show resolved Hide resolved
@betatim
Copy link
Member

betatim commented Apr 3, 2024

I am not sure I understand why the docs build fails. The error is this:

/home/circleci/project/sklearn/calibration.py:docstring of sklearn.calibration.CalibrationDisplay:74: WARNING: Exception occurred in plotting sklearn-calibration-CalibrationDisplay-2
 from /home/circleci/project/doc/modules/generated/sklearn.calibration.CalibrationDisplay.rst:
Traceback (most recent call last):
  File "/home/circleci/mambaforge/envs/testenv/lib/python3.9/site-packages/matplotlib/sphinxext/plot_directive.py", line 472, in run_code
    exec(code, ns)
  File "<string>", line 2
    For another example of usage, see:
        ^
SyntaxError: invalid syntax

Which I think means that too much of the doc string is selected by matplotlib as code. However, when I build the docs locally this doesn't happen. @ogrisel do you have an idea where to start looking maybe?

@@ -1391,6 +1396,9 @@ def from_predictions(
>>> y_prob = clf.predict_proba(X_test)[:, 1]
>>> disp = CalibrationDisplay.from_predictions(y_test, y_prob)
>>> plt.show()

For another example of usage, see:
Copy link
Member

Choose a reason for hiding this comment

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

This is the bit that is causing the error.

@ogrisel
Copy link
Member

ogrisel commented Apr 3, 2024

The plot_directive.py of that version of matplotlib probably has a bug and it might be necessary to debug or search for similar issues in the matplotlib issue tracker.

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.

None yet

3 participants