TheDocumentation Index
Fetch the complete documentation index at: https://mintlify.com/Tumo505/SSL-for-ECG-classification/llms.txt
Use this file to discover all available pages before exploring further.
ssrl_ecg.visualization module provides utilities for producing consistent, publication-ready figures from ECG classification experiments. This page documents set_publication_style, which configures matplotlib globally so that every subsequent figure shares the same typographic and aesthetic standards, and plot_roc_curve, which renders a labelled ROC curve on any axes object, handling both binary and multi-class inputs automatically.
set_publication_style
matplotlib.rcParams updates that configure every subsequent figure for print or journal submission quality. Call this once at the top of any script or notebook that generates figures.
Returns None. All effects are applied as global side effects on plt.rcParams.
rcParams applied
| Parameter | Value | Effect |
|---|---|---|
figure.dpi | 300 | Screen rendering at print resolution |
figure.figsize | (8, 6) | Default figure dimensions in inches |
font.size | 11 | Base font size for all text elements |
font.family | "sans-serif" | Clean sans-serif typeface matching most journal styles |
axes.labelsize | 12 | Axis label font size |
axes.titlesize | 13 | Axes title font size |
xtick.labelsize | 10 | X-axis tick label size |
ytick.labelsize | 10 | Y-axis tick label size |
legend.fontsize | 10 | Legend entry font size |
lines.linewidth | 2 | Default line weight |
lines.markersize | 6 | Default marker size |
axes.grid | True | Grid enabled on all axes |
grid.alpha | 0.3 | Subtle, non-distracting grid |
savefig.dpi | 300 | DPI used when saving to file |
savefig.bbox | "tight" | Auto-crop whitespace on save |
Example
plot_roc_curve
Ground-truth labels. Accepts:
- 1D
[n_samples]— binary labels{0, 1} - 2D
[n_samples, n_classes]— multi-label binary matrix; columns are averaged to a single score per sample before curve computation
Predicted scores or probabilities. Accepts:
- 1D
[n_samples]— binary classifier output - 2D
[n_samples, n_classes]— multi-class probability matrix; columns are averaged column-wise to a single scalar per sample
Name of the model or method to display in the legend. Displayed as
"{label} (AUC = 0.XXX)". Leave empty to show only the AUC value.Axes object on which to draw. When
None, a new figure and axes are created internally. Pass an existing ax to overlay multiple curves on a single plot.Matplotlib color string or hex code for the ROC curve line. Accepts any format accepted by
matplotlib.axes.Axes.plot (e.g. "blue", "#1f77b4", "C0").The figure object. Returns
None when an existing ax was passed (the figure is managed by the caller in that case).The axes object containing the plotted curve. Always returned regardless of whether
ax was supplied.The scalar AUC value computed for this curve. Useful for programmatic comparison or logging without inspecting the legend text.
Multi-class averaging
Wheny_prob is a 2D array with more than one column, plot_roc_curve reduces it to a 1D score vector by taking the column-wise mean (y_prob.mean(axis=1)). The same averaging is applied to y_true when it is 2D. This produces a single aggregate ROC curve representing overall classifier performance across all classes — the equivalent of a macro-level summary curve.
Axes decoration applied
Every call toplot_roc_curve applies the following decoration to the target axes:
| Element | Value |
|---|---|
| X-axis label | "False Positive Rate" |
| Y-axis label | "True Positive Rate" |
| Title | "Receiver Operating Characteristic Curve" |
| Diagonal reference line | Dashed black, alpha=0.5, labelled "Random" |
| Axis limits | [-0.02, 1.02] on both axes |
| Grid | True, alpha=0.3 |
| Legend | Lower-right, fontsize=10, includes AUC value |
Because
plot_roc_curve sets the title, axis labels, and legend on every call, overlaying multiple curves (e.g. SimCLR, BYOL, supervised baseline) on the same axes is safe — each call simply overwrites the static decoration elements with identical values while adding a new line to the legend.Complete Multi-Model Comparison Example
Single-Model Example
Collecting AUC Scores Programmatically
When running a sweep over multiple checkpoints or seeds, capture the returnedroc_auc values for downstream aggregation without parsing the legend: