@@ -88,21 +88,34 @@ def __init__(
88
88
Args:
89
89
label_values_or_threshold (Any): List of label values or threshold to indicate positive
90
90
outcome used for bias metrics.
91
- facet_name (str): Sensitive attribute in the input data for which we like to compare
92
- metrics.
91
+ facet_name (str or [str] ): String or List of strings of sensitive attribute(s) in the
92
+ input data for which we like to compare metrics.
93
93
facet_values_or_threshold (list): Optional list of values to form a sensitive group or
94
94
threshold for a numeric facet column that defines the lower bound of a sensitive
95
95
group. Defaults to considering each possible value as sensitive group and
96
96
computing metrics vs all the other examples.
97
+ If facet_name is a list, this needs to be None or a List consisting of lists or None
98
+ with the same length as facet_name list.
97
99
group_name (str): Optional column name or index to indicate a group column to be used
98
100
for the bias metric 'Conditional Demographic Disparity in Labels - CDDL' or
99
101
'Conditional Demographic Disparity in Predicted Labels - CDDPL'.
100
102
"""
101
- facet = {"name_or_index" : facet_name }
102
- _set (facet_values_or_threshold , "value_or_threshold" , facet )
103
+ if isinstance (facet_name , str ):
104
+ facet = {"name_or_index" : facet_name }
105
+ _set (facet_values_or_threshold , "value_or_threshold" , facet )
106
+ facet_list = [facet ]
107
+ elif facet_values_or_threshold is None or len (facet_name ) == len (facet_values_or_threshold ):
108
+ facet_list = []
109
+ for i , single_facet_name in enumerate (facet_name ):
110
+ facet = {"name_or_index" : single_facet_name }
111
+ if facet_values_or_threshold is not None :
112
+ _set (facet_values_or_threshold [i ], "value_or_threshold" , facet )
113
+ facet_list .append (facet )
114
+ else :
115
+ raise ValueError ("Wrong combination of argument values passed" )
103
116
self .analysis_config = {
104
117
"label_values_or_threshold" : label_values_or_threshold ,
105
- "facet" : [ facet ] ,
118
+ "facet" : facet_list ,
106
119
}
107
120
_set (group_name , "group_variable" , self .analysis_config )
108
121
0 commit comments