responsible-ai-toolbox icon indicating copy to clipboard operation
responsible-ai-toolbox copied to clipboard

Support for multiple sensitive features in Fairness dashboard

Open michaelamoako opened this issue 3 years ago • 3 comments

Need by_group (currently in MetricFrame) in the Fairness dashboard. Found a temporary workaround (described below)

#sensitive_features is a list of the sensitive columns in the pandas dataframe (named pdf), golden labels corresponds to the column of ground truth labels in the pdf, and predictions corresponds to the predictions of the classifier 

sensitive_cols=pdf.loc[:][sensitive_features]

`def append_cols(grouped_col, pdf, cols):
    pdf[grouped_col] = ["" for i in range(len(cols))]
    for col in cols: 
        pdf[grouped_col] += cols[col]
        
sensitive_features_grouped = "-".join(sensitive_features)
append_cols(sensitive_features_grouped, pdf, sensitive_cols)  
#Now the pdf has the new column that is a combination of the sensitive features `

FairnessDashboard(sensitive_features=pdf[sensitive_features_grouped],
                y_true=golden_labels,
                y_pred=predictions)`

Note: sensitive_cols can also be modified to see the grouped column, in addition to other sensitive columns

michaelamoako avatar Apr 30 '21 22:04 michaelamoako

Just to confirm: You want support for multiple sensitive features, right?

romanlutz avatar May 04 '21 04:05 romanlutz

Yes - though I did find a work around (which I included the code for above).

michaelamoako avatar May 04 '21 14:05 michaelamoako

Thanks for calling attention to this. It's been on our radar for a while, but we've not had time to think about the best way to show it in the UX.

riedgar-ms avatar May 07 '21 14:05 riedgar-ms