Plotting utilities

Plot postprocessing solutions and frontiers.

error_parity.plotting.plot_postprocessing_solution(*, postprocessed_clf, plot_roc_curves=False, plot_roc_hulls=True, plot_group_optima=True, plot_group_triangulation=True, plot_global_optimum=True, plot_diagonal=True, plot_relaxation=False, group_name_map=None, figure=None, **fig_kwargs)[source]

Plots the group-specific solutions found for this predictor.

Parameters:
  • postprocessed_clf (RelaxedThresholdOptimizer) – A postprocessed classifier already fitted on some data.

  • plot_roc_curves (bool, optional) – Whether to plot the global ROC curves, by default False.

  • plot_roc_hulls (bool, optional) – Whether to plot the global ROC convex hulls, by default True.

  • plot_group_optima (bool, optional) – Whether to plot the group-specific optima, by default True.

  • plot_group_triangulation (bool, optional) – Whether to plot the triangulation of a group-specific solution, when such triangulation is needed to achieve a target ROC point.

  • plot_global_optimum (bool, optional) – Whether to plot the global optimum ROC point, by default True.

  • plot_diagonal (bool, optional) – Whether to plot the ROC diagonal with FPR=TPR, by default True.

  • plot_relaxation (bool, optional) – Whether to plot the constraint relaxation bounding box, by default False.

  • group_name_map (dict, optional) – A dictionary mapping each group’s value to an appropriate name to show in the plot legend, by default None.

  • figure (matplotlib.figure.Figure, optional) – A matplotlib figure to use when plotting, by default will generate a new figure for plotting.

error_parity.plotting.plot_postprocessing_frontier(postproc_results_df, *, perf_metric, disp_metric, show_data_type, constant_clf_perf, model_name=None, color='black')[source]

Helper to plot the given post-processing frontier results.

Will use bootstrapped results if available, including plotting confidence intervals.

Parameters:
  • postproc_results_df (pd.DataFrame) – The DataFrame containing postprocessing results. This should be the output of a call to compute_postprocessing_curve(.).

  • perf_metric (str) – Which performance metric to plot (horizontal axis).

  • disp_metric (str) – Which disparity metric to plot (vertical axis).

  • show_data_type (str) – The type of data to show results for; usually this will be “test”.

  • constant_clf_perf (float) – Performance achieved by the constant classifier; this is the point of lowest performance and lowest disparity achievable by postprocessing.

  • model_name (str, optional) – Shown in the plot legend. Name of the model to be postprocessed.

  • color (str, optional) – Which color to use for plotting the postprocessing curve, by default “black”.