utils.py
def static_label(data, sensi_atts, target_name):
    """
    Function used for static label generation.

    args:
        data: raw input data. pandas dataframe.
        sensi_atts: sensible attributes used to generate static labels. String.
        target_name: target attributes. String.

    return:
        res: dictionaty storing categories to static labels.
    """

    groupby_cols = sensi_atts+[target_name]
    placeholder_att = list(set(data.columns).difference(groupby_cols))[0]
    pivot_data = data.pivot_table(index=sensi_atts,
                   columns=target_name,
                   values=placeholder_att,
                   fill_value=0,
                   aggfunc='count').unstack(fill_value=0).stack()

    # pivot_data.loc['Female'].apply(lambda x: )
    first_index = set([item[0] for item in list(pivot_data.index)])
    res = {}
    for idx in first_index:
        sum_to_norm = pivot_data.loc[idx].sum().to_numpy()
        res.update({(idx, key): value for key, value in round(pivot_data.loc[idx]/sum_to_norm, 3).T.to_dict().items()})
    return res

    Function used for static label generation.

    args:
        data: raw input data. pandas dataframe.
        sensi_atts: sensible attributes used to generate static labels. String.
        target_name: target attributes. String.

    return:
        res: dictionaty storing categories to static labels.
    
Function used for static label generation.
args:
data: raw input data. pandas dataframe.
sensi_atts: sensible attributes used to generate static labels. String.

dictionaty storing categories to static labels.
Function used for static label generation . args : data : raw input data . pandas dataframe . sensi_atts : sensible attributes used to generate static labels . String . dictionaty storing categories to static labels .
def static_label(data, sensi_atts, target_name):
    groupby_cols = sensi_atts+[target_name]
    placeholder_att = list(set(data.columns).difference(groupby_cols))[0]
    pivot_data = data.pivot_table(index=sensi_atts,
                   columns=target_name,
                   values=placeholder_att,
                   fill_value=0,
                   aggfunc='count').unstack(fill_value=0).stack()
    first_index = set([item[0] for item in list(pivot_data.index)])
    res = {}
    for idx in first_index:
        sum_to_norm = pivot_data.loc[idx].sum().to_numpy()
        res.update({(idx, key): value for key, value in round(pivot_data.loc[idx]/sum_to_norm, 3).T.to_dict().items()})
    return res
def static_label ( data , sensi_atts , target_name ) : groupby_cols = sensi_atts + [ target_name ] placeholder_att = list ( set ( data . columns ) . difference ( groupby_cols ) ) [ 0 ] pivot_data = data . pivot_table ( index = sensi_atts , columns = target_name , values = placeholder_att , fill_value = 0 , aggfunc = 'count' ) . unstack ( fill_value = 0 ) . stack ( ) first_index = set ( [ item [ 0 ] for item in list ( pivot_data . index ) ] ) res = { } for idx in first_index : sum_to_norm = pivot_data . loc [ idx ] . sum ( ) . to_numpy ( ) res . update ( { ( idx , key ) : value for key , value in round ( pivot_data . loc [ idx ] / sum_to_norm , 3 ) . T . to_dict ( ) . items ( ) } ) return res
Function used for static label generation.
Function used for static label generation .
"""
    Function used for static label generation.

    args:
        data: raw input data. pandas dataframe.
        sensi_atts: sensible attributes used to generate static labels. String.
        target_name: target attributes. String.

    return:
        res: dictionaty storing categories to static labels.
    """ # pivot_data.loc['Female'].apply(lambda x: )
data
sensi_atts
target_name