Skip to content

Implement count as a metric - #812

Merged
romanlutz merged 1 commit into
fairlearn:mainfrom
stephenrobic:supporting_count_as_a_metric
May 25, 2021
Merged

romanlutz merged 1 commit into
fairlearn:mainfrom
stephenrobic:supporting_count_as_a_metric

Conversation

@stephenrobic

@stephenrobic stephenrobic commented May 19, 2021 •

Copy link
Copy Markdown
Contributor

This PR seeks to implement count as a metric, in order to decipher the number of data points in each group when working with MetricFrame.

The following were updated:

  • Updated user guide to add new count metric wherever more than 1 metric is passed to MetricFrame
  • Added count to notebooks wherever MetricFrame.
  • Added new count function in fairlearn.metrics.extra_metrics
  • Added count to fairlearn.metrics.group_metric_set (for consistency, even though deprecated)
  • Added unit tests and fixed existing tests pertaining to count
    • Fixed expected json results in unit.metrics.sample_dashboards)
  • Added self to AUTHORS.md (and look forward to contributing more)

This is in reference to issue #737

@stephenrobic

Copy link
Copy Markdown
Contributor Author

👋 @romanlutz, let me know what you think.

@romanlutz romanlutz left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

This is great! Thanks for the comprehensive set of changes including all the existing occurrences throughout the user guide! Would you mind adding a few simple unit tests? I'm thinking for an empty group, group of 1, and something slightly longer.

Comment thread docs/user_guide/assessment.rst Resolved
Comment thread docs/user_guide/assessment.rst Resolved
@stephenrobic

Copy link
Copy Markdown
Contributor Author

Thanks for the speedy feedback 😄 I can definitely play around with adding some unit tests.

@romanlutz romanlutz left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Make sure to also run flake8 from the repo root to get all linting issues. There's currently only 1 but you never know 😄

Comment thread docs/user_guide/assessment.rst Resolved
Comment thread fairlearn/metrics/__init__.py Resolved
Comment thread fairlearn/metrics/_count.py Outdated
y_pred : array_like
The predicted labels (ignored)

sample_weight : array_like

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

If you're going to ignore it, don't include it.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

I'll remove it. I was trying to be consistent with this:

The argument `pos_label` specifies the 'good' outcome. For consistency with
other metric functions, the ``y_true`` argument is required, but ignored.
Parameters
----------
y_true : array_like
The true labels (ignored)

Comment thread fairlearn/metrics/_group_metric_set.py Resolved
Comment thread fairlearn/metrics/__init__.py Resolved
@stephenrobic stephenrobic changed the title Implement count as a metric Implement count as a metric May 21, 2021
@stephenrobic stephenrobic changed the title Implement count as a metric Implement count as a metric May 21, 2021
@stephenrobic
stephenrobic force-pushed the supporting_count_as_a_metric branch from 8a76289 to 147b7f5 Compare May 21, 2021 01:17
@stephenrobic

Copy link
Copy Markdown
Contributor Author

I believe I have fixed everything mentioned here. Thanks for the feedback. How does this look?

@romanlutz romanlutz left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Looks great! There's the small comment about "subjects" I'd prefer to have changed, but otherwise this looks ready to merge to me. Let's see if the gates pass and @riedgar-ms probably should take another look as well.

Comment thread docs/user_guide/assessment.rst Resolved
@stephenrobic

stephenrobic commented May 21, 2021 •

Copy link
Copy Markdown
Contributor Author

I got that all fixed. I forgot to take out that line about "subjects", when I added the new one referring to "groups" above it. 🤦 I saw that issue #815 earlier when building the docs on my end, so that's great. Thanks for the thorough review! I learned a lot just by digging into this small new feature.

Comment thread fairlearn/metrics/_extra_metrics.py Resolved
@stephenrobic
stephenrobic force-pushed the supporting_count_as_a_metric branch 4 times, most recently from ae22ddc to c74a5f9 Compare May 21, 2021 16:50
@stephenrobic

Copy link
Copy Markdown
Contributor Author

I'm working on fixing the broken tests after adding the count function.

@stephenrobic
stephenrobic force-pushed the supporting_count_as_a_metric branch 3 times, most recently from 85c43bb to df6eee6 Compare May 21, 2021 18:15
@stephenrobic

Copy link
Copy Markdown
Contributor Author

I have fixed the unit tests, so that count is included.

@romanlutz

Copy link
Copy Markdown
Member

LGTM! @riedgar-ms feel free to merge if you're happy with it.

@riedgar-ms riedgar-ms left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Thanks for working on this!

@romanlutz

Copy link
Copy Markdown
Member

@stephenrobic last change request 😄 There's a file called CHANGES.md in the repo root directory. Can you add a line to the next release (0.7.0) saying that count has been added as a new metric? I'll merge once that's there.

@stephenrobic
stephenrobic force-pushed the supporting_count_as_a_metric branch from df6eee6 to 9345dd9 Compare May 25, 2021 21:21
@stephenrobic

Copy link
Copy Markdown
Contributor Author

@riedgar-ms @romanlutz It was my pleasure to work on this and learn from it. Thank you for guiding me through this!

@romanlutz
romanlutz merged commit 9de9777 into fairlearn:main May 25, 2021
@romanlutz

Copy link
Copy Markdown
Member

Thanks @stephenrobic for this fantastic contribution!

@stephenrobic
stephenrobic deleted the supporting_count_as_a_metric branch May 27, 2021 22:44
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.

3 participants