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 Plot ROC AUC curves #869

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

Conversation

kstohr
Copy link

@kstohr kstohr commented Jun 18, 2021

No description provided.

Reference
----------
MetricFrame:
https://fairlearn.org/v0.6.2/api_reference/fairlearn.metrics.html
Copy link
Member

Choose a reason for hiding this comment

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

This should be a reference to the class in the docs, not a full URL

Copy link
Author

Choose a reason for hiding this comment

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

Yep. Will fix when I run the documentation (I didn't run Sphinx yet.)

for name in sensitive_index:
grp_y_true = self.sensitive_series[name][0]
grp_y_score = self.sensitive_series[name][1]
display = self.plot_roc(
Copy link
Member

Choose a reason for hiding this comment

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

Is it possible to use self.plot_roc as the metric itself, with judicious use of functools.partial to bind the other arguments (not sure if that works with **kwargs).

Copy link
Author

Choose a reason for hiding this comment

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

@riedgar-ms Yeah, I tried that at first. It may be possible, but when I tried it I ran into some issues with the MetricFrame class because it computes the metric on instantiation, and all I am actually using from that class is the group by function to split the data. It was far easier to pass a placeholder function. Open to suggestions. However, I think the work that needs to happen is some small tweaks to MetricFrame..So holding out for us to determine the approach to MetricFrame and then we can come back to this and refactor it if needed.

Copy link
Member

@romanlutz romanlutz left a comment

Choose a reason for hiding this comment

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

@kstohr thanks for sharing, this is great! I've put in a few preliminary comments. It would be nice to have a few screenshots of how it renders in the example, and a brief PR description that links to the corresponding issue. Let me know if you have questions or doubts about my comments. I'm always happy to chat!

examples/plot_roc_auc.py Show resolved Hide resolved
fairlearn/metrics/_roc_auc.py Show resolved Hide resolved
"""
Provides utilties for generating AUC scores, ROC curves
and plotting ROC curves grouped by sensitive feature. Depends on
the Fairlearn MetricFrame class to split the input by sensitive feature.
Copy link
Member

Choose a reason for hiding this comment

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

nit: use ReST directives, e.g.,

:class:`fairlearn.metrics.MetricFrame`

Copy link
Author

Choose a reason for hiding this comment

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

@romanlutz Will that markdown automatically create a link to the API in the docs when I build the docs?

Copy link
Member

Choose a reason for hiding this comment

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

Yes! It's restructured text (ReST) rather than markdown, but that's exactly what it does. I go back to the ReST guide quite a lot these days: https://www.sphinx-doc.org/en/master/usage/restructuredtext/basics.html

fairlearn/metrics/_roc_auc.py Show resolved Hide resolved
fairlearn/metrics/_roc_auc.py Show resolved Hide resolved
fairlearn/metrics/_roc_auc.py Show resolved Hide resolved
examples/plot_roc_auc.py Show resolved Hide resolved
examples/plot_roc_auc.py Show resolved Hide resolved
examples/plot_roc_auc.py Show resolved Hide resolved
@kstohr
Copy link
Author

kstohr commented Jun 22, 2021

Ok, let me make those changes. We still have to build tests and I didn't actually run sphinx. I wrote the example, but didn't really look at how it will format in the docs. I also would like to give some direction on how you would mitigate a model once having run the ROC Curves.

@romanlutz
Copy link
Member

@kstohr thanks for patiently working through the comments 🙂

In terms of mitigation I would suggest restricting this PR to generating the ROC curves. It will keep growing in scope otherwise and there may be different viewpoints on how one can mitigate that, which will drag everything out quite a bit. It's probably preferable to keep the change as small as possible and then add to it in follow-up PRs. We can certainly get the conversation started, though!

@romanlutz
Copy link
Member

@kstohr do you want to revisit this and perhaps set up some time to talk about testing as we had planned a while back?

@romanlutz
Copy link
Member

@kstohr do you want to revisit this and perhaps set up some time to talk about testing as we had planned a while back?

Ping @kstohr 🙂 I suppose we can go ahead an assume that others can take over this PR if we don't hear back by 12/20 (two weeks from now). If you're still interested in getting back to this at a later point, @kstohr, feel free to say so!

@kstohr
Copy link
Author

kstohr commented Dec 7, 2021 via email

@romanlutz romanlutz changed the title Plot roc curves ENH Plot ROC AUC curves Dec 15, 2021
@romanlutz romanlutz linked an issue Feb 4, 2023 that may be closed by this pull request
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.

plot_roc_curves(scores, y_true, sensitive_features)
3 participants