You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
It's desired to know the number of data points in each group when working with MetricFrame, and that can be achieved by passing a function which returns the length of its input. For instance:
# report the above scores in a table.fromfairlearn.metricsimportMetricFrameimportsklearn.metricsasskmy_pred=np.asarray(df.y_pred).astype(float)
y_true=np.asarray(df.FraudLabel=="true").astype(int)
multi_metric=MetricFrame({
'average precision':skm.average_precision_score,
'roc-auc': skm.roc_auc_score,
'count': lambdax, y: len(x)},
y_true, y_pred,
sensitive_features=df.gender)
multi_metric.by_group
We don't necessarily need to change anything in the code or API for this, but we should document it in the user guide and/or the API reference to let people know how it can be done.
I like this a lot. The lambda x, y: len(x) isn't super straightforward if you're not familiar with how to write a metric function. Should we just define the count function like we did with selection_rate so that people can import it and pass it without having to write the code themselves?
Totally agree on documenting this. I guess the tasks here would be
to look at the user guide of MetricFrame and add that new count metric wherever we have 2 or more metrics passed to the MetricFrame, and write a short sentence or two on what this does (i.e., "show the number of people in the corresponding group")
to look through notebooks and add count whenever we have a MetricFrame.
To clarify the count function proposal. I'm assuming we're just talking about adding fairlearn.metrics.count, but not doing anything with the MetricFrame API right?
To clarify the count function proposal. I'm assuming we're just talking about adding fairlearn.metrics.count, but not doing anything with the MetricFrame API right?
@romanlutz Hi - I was very busy the past 2 weeks and wasn't able to contribute. So sorry! Would you be able to find me another issue that would be interesting to work on?
Activity
romanlutz commentedon Apr 9, 2021
I like this a lot. The
lambda x, y: len(x)isn't super straightforward if you're not familiar with how to write a metric function. Should we just define thecountfunction like we did withselection_rateso that people can import it and pass it without having to write the code themselves?Totally agree on documenting this. I guess the tasks here would be
MetricFrameand add that newcountmetric wherever we have 2 or more metrics passed to theMetricFrame, and write a short sentence or two on what this does (i.e., "show the number of people in the corresponding group")countwhenever we have aMetricFrame.hildeweerts commentedon Apr 12, 2021
I like the convenience of a separate
countfunction, it makes it more beginner friendly I think. Do we need to open a separate issue for that?adrinjalali commentedon Apr 12, 2021
I think the same issue/pr could do both the doc and the function.
MiroDudik commentedon Apr 16, 2021
To clarify the
countfunction proposal. I'm assuming we're just talking about addingfairlearn.metrics.count, but not doing anything with theMetricFrameAPI right?adrinjalali commentedon Apr 17, 2021
Correct :)
vamsidesu5 commentedon Apr 22, 2021
Hey I can take this issue up!
adrinjalali commentedon Apr 23, 2021
Sure, it's yours @vamsidesu5
stephenrobic commentedon May 17, 2021
I will begin working on this issue now. Thanks for your guidance @romanlutz
romanlutz commentedon May 17, 2021
Thanks @stephenrobic ! @vamsidesu5 let me know if you want to do any other issues! I'd be happy to find you something.
vamsidesu5 commentedon May 18, 2021
@romanlutz Hi - I was very busy the past 2 weeks and wasn't able to contribute. So sorry! Would you be able to find me another issue that would be interesting to work on?
romanlutz commentedon May 28, 2021
Closing since @stephenrobic 's PR #812 was merged a week ago.