Plotting Utilities

utils.plot.get_mean_std(metric_list)[source]

Calculate the mean and standard deviation of a list of metric values.

Parameters: metric_list (list): List of numerical metric values.

Returns: tuple: Mean and standard deviation of the input list.

utils.plot.plot_metrics(plot_data, metric_name, repair_levels, protected_attributes)[source]

Plot mean and standard deviation of a given metric across different repair levels for each sensitive attribute using error bars.

Parameters: plot_data (dict): Dictionary containing metric statistics by attribute and repair level.

Expected keys format: plot_data[attribute][f”{metric_name}_mean_{repair_level}”] and plot_data[attribute][f”{metric_name}_std_{repair_level}”]

metric_name (str): Name of the metric to plot. repair_levels (list): List of repair levels used in the fairness pipeline. protected_attributes (list): List of sensitive attributes.

utils.plot.plot_metrics_grouped(results, protected_attributes, repair_levels)[source]

Create grouped bar plots of performance and fairness metrics across repair levels for each protected attribute. Y-axis limits are synchronized per attribute row (performance and fairness), allowing for easy comparison within attributes.

Parameters: - results (dict): Nested dictionary of results keyed by attribute and repair level. - protected_attributes (list): List of sensitive attribute names. - repair_levels (list): List of repair levels used in the experiment.

utils.plot.print_fairness_results_table(plot_data, metrics_keys, repair_levels)[source]

Print fairness and performance metrics in a formatted table.

Parameters: - plot_data: dict of aggregated metrics (mean and std) from experiments - metrics_keys: list of metric names (e.g., ‘accuracy’, ‘precision’, etc.) - repair_levels: list of levels of fairness constraint used (e.g., [0, 0.5, 1])