responsible-ai-toolbox
responsible-ai-toolbox copied to clipboard
Support for multiple sensitive features in Fairness dashboard
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
Just to confirm: You want support for multiple sensitive features, right?
Yes - though I did find a work around (which I included the code for above).
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.