Skip to content

Error: fairness.plot_bias privileged_group with numerical values #7

@Nathanlauga

Description

@Nathanlauga

Errors with numerical attributes in fairness.plot_bias.

Also check fairness.compute_metrics to handle numerical values.

privileged_group = {'SEX': [1]}
fairness.plot_bias(y_test, y_pred_a, X_test, privileged_group, pos_label=0)
---------------------------------------------------------------------------
TypeError                                 Traceback (most recent call last)
<ipython-input-73-ecba7ab9a910> in <module>
----> 1 fairness.plot_bias(y_test, y_pred_a, X_test, privileged_group, pos_label=0)

/opt/conda/lib/python3.7/site-packages/transparentai/fairness/fairness_plots.py in plot_bias(y_true, y_pred, df, privileged_group, pos_label, regr_split, with_text, **kwargs)
    315     for attr, bias_scores in scores.items():
    316         ax = fig.add_subplot(gs[row, :])
--> 317         plot_attr_title(ax, attr, df, privileged_group)
    318 
    319         axes = [fig.add_subplot(gs[row+1+j, i])

/opt/conda/lib/python3.7/site-packages/transparentai/fairness/fairness_plots.py in plot_attr_title(ax, attr, df, privileged_group)
    137         attr, df, privileged_group, privileged=False)
    138 
--> 139     priv_text = format_priv_text(priv_values, max_char=30)
    140     unpriv_text = format_priv_text(unpriv_values, max_char=30)
    141 

/opt/conda/lib/python3.7/site-packages/transparentai/fairness/fairness_plots.py in format_priv_text(values, max_char)
     88 
     89     for val in values:
---> 90         if (len(val) + len(priv_text) > max_char) & (priv_text != ''):
     91             priv_text = priv_text[:-2] + ' and others  '
     92             break

TypeError: object of type 'int' has no len()

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions