pycsamt.ai.plot.convergence#

Training convergence visualisation.

plot_convergence() renders training and validation loss curves with a shaded 1-σ band (when multiple runs are provided), a vertical marker at the early-stopping epoch, and an LR schedule indicator.

Usage#

>>> from pycsamt.ai.plot.convergence import plot_convergence
>>> fig = plot_convergence(trainer.history)
>>> fig.savefig("convergence.png", dpi=300)

Functions

plot_convergence(history, *[, ax, ...])

Plot train / validation loss curves from a trainer history dict.

plot_lr_schedule(lr_history, *[, ax, title, ...])

Standalone learning-rate schedule plot.

pycsamt.ai.plot.convergence.plot_convergence(history, *, ax=None, log_scale=True, best_epoch=None, smoothing=0.0, show_lr=True, title='Training convergence', style=True)[source]#

Plot train / validation loss curves from a trainer history dict.

Parameters:
  • history (dict or list of dict) – A dict with keys 'train_loss' and 'val_loss' (and optionally 'lr'), as returned by history. A list of such dicts (from multiple runs) activates the mean ± 1-σ band mode.

  • ax (Axes or None) – Target axes. If None, a new figure/axes is created.

  • log_scale (bool) – Log₁₀ y-axis for the loss.

  • best_epoch (int or None) – If given, draw a vertical dashed line at this epoch.

  • smoothing (float in [0, 1)) – Exponential moving average smoothing coefficient. 0 = no smoothing.

  • show_lr (bool) – Overlay learning rate on a twin y-axis (if 'lr' in history).

  • title (str) – Axes title.

  • style (bool) – Apply EMStyle.

Returns:

fig

Return type:

Figure

pycsamt.ai.plot.convergence.plot_lr_schedule(lr_history, *, ax=None, title='Learning rate schedule', style=True)[source]#

Standalone learning-rate schedule plot.

Parameters:
  • lr_history (list of float) – Per-epoch LR values (from trainer.history['lr']).

  • ax (Axes or None)

  • title (str)

  • style (bool)

Returns:

ax

Return type:

Axes