ssbc.reporting.visualization

Visualization and reporting utilities for conformal prediction results.

Functions

plot_parallel_coordinates_plotly(df[, ...])

Create interactive parallel coordinates plot for hyperparameter sweep results.

report_prediction_stats(prediction_stats, ...)

Report rigorous statistics for Mondrian conformal prediction with valid CIs.

ssbc.reporting.visualization.report_prediction_stats(prediction_stats, calibration_result, operational_bounds_per_class=None, marginal_operational_bounds=None, verbose=True)[source]

Report rigorous statistics for Mondrian conformal prediction with valid CIs.

Only displays statistics with valid confidence intervals: - Per-class statistics from calibration data (valid within class) - Per-class operational bounds from cross-validation (rigorous PAC bounds) - Marginal operational bounds from cross-validated Mondrian (rigorous PAC bounds)

Does NOT display marginal statistics from calibration data (invalid CIs for Mondrian).

Parameters:
  • prediction_stats (dict) – Output from mondrian_conformal_calibrate (second return value)

  • calibration_result (dict) – Output from mondrian_conformal_calibrate (first return value)

  • operational_bounds_per_class (dict[int, OperationalRateBoundsResult], optional) – Per-class operational bounds (from generate_rigorous_pac_report)

  • marginal_operational_bounds (OperationalRateBoundsResult, optional) – Marginal operational bounds (from generate_rigorous_pac_report)

  • verbose (bool, default=True) – If True, print detailed statistics to stdout

Returns:

Structured summary with valid CIs: - Keys 0, 1 for per-class statistics - Key ‘marginal_bounds’ if marginal_operational_bounds provided

Return type:

dict

Examples

>>> # Get operational bounds from rigorous PAC report
>>> from ssbc import generate_rigorous_pac_report
>>> report = generate_rigorous_pac_report(labels, probs, alpha_target=0.10, delta=0.10)
>>> cal_result = report['calibration_result']
>>> pred_stats = report['prediction_stats']
>>> op_bounds = report['pac_bounds_class_0']  # Per-class bounds
>>> marginal = report['pac_bounds_marginal']  # Marginal bounds
>>> summary = report_prediction_stats(pred_stats, cal_result, op_bounds, marginal)
ssbc.reporting.visualization.plot_parallel_coordinates_plotly(df, columns=None, color='err_all', color_continuous_scale=None, title='Mondrian sweep interactive parallel coordinates', height=600, base_opacity=0.9, unselected_opacity=0.06)[source]

Create interactive parallel coordinates plot for hyperparameter sweep results.

Parameters:
  • df (pd.DataFrame) – DataFrame with hyperparameter sweep results

  • columns (list of str, optional) – Columns to display in parallel coordinates Default: [‘a0’,’d0’,’a1’,’d1’,’cov’,’sing_rate’,’err_all’,’err_pred0’,’err_pred1’,’err_y0’,’err_y1’,’esc_rate’]

  • color (str, default='err_all') – Column to use for coloring lines

  • color_continuous_scale (plotly colorscale, optional) – Color scale for the lines

  • title (str, default="Mondrian sweep – interactive parallel coordinates") – Plot title

  • height (int, default=600) – Plot height in pixels

  • base_opacity (float, default=0.9) – Opacity of selected lines

  • unselected_opacity (float, default=0.06) – Opacity of unselected lines (creates contrast)

Returns:

Interactive plotly figure

Return type:

plotly.graph_objects.Figure

Examples

>>> import pandas as pd
>>> df = sweep_hyperparams_and_collect(...)
>>> fig = plot_parallel_coordinates_plotly(df, color='err_all')
>>> fig.show()  # In notebook
>>> # Or save: fig.write_html("sweep_results.html")