@@ -88,21 +88,34 @@ def __init__(
8888 Args:
8989 label_values_or_threshold (Any): List of label values or threshold to indicate positive
9090 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.
9393 facet_values_or_threshold (list): Optional list of values to form a sensitive group or
9494 threshold for a numeric facet column that defines the lower bound of a sensitive
9595 group. Defaults to considering each possible value as sensitive group and
9696 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.
9799 group_name (str): Optional column name or index to indicate a group column to be used
98100 for the bias metric 'Conditional Demographic Disparity in Labels - CDDL' or
99101 'Conditional Demographic Disparity in Predicted Labels - CDDPL'.
100102 """
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" )
103116 self .analysis_config = {
104117 "label_values_or_threshold" : label_values_or_threshold ,
105- "facet" : [ facet ] ,
118+ "facet" : facet_list ,
106119 }
107120 _set (group_name , "group_variable" , self .analysis_config )
108121
0 commit comments