history
Training History Plotting API
This module provides utility functions to plot training history metrics.
Functions:
-
plot_history_metrics
–Plot training history metrics
Functions
plot_history_metrics
plot_history_metrics(history: dict[str, list[float]], metrics: list[str], save_path: Path | None = None, include_val: bool = True, figsize: tuple[int, int] = (9, 5), colors: tuple[str | tuple[str, str]] = ('blue', 'orange'), stack: bool = False, title: str | None = None, **kwargs) -> tuple[plt.Figure, plt.Axes]
Plot training history metrics returned by model.fit.
Parameters:
-
history
(dict[str, list[float]]
) –Training history
-
metrics
(list[str]
) –Metrics to plot
-
save_path
(Path | None
, default:None
) –Path to save plot. Defaults to None.
-
include_val
(bool
, default:True
) –Include validation metrics. Defaults to True.
-
figsize
(tuple[int, int]
, default:(9, 5)
) –Figure size. Defaults to (9, 5).
-
colors
(tuple[str | tuple[str, str]]
, default:('blue', 'orange')
) –Colors for train and val. Defaults to ("blue", "orange").
-
stack
(bool
, default:False
) –Stack metrics. Defaults to False.
-
title
(str | None
, default:None
) –Title for plot. Defaults
Returns:
-
tuple[Figure, Axes]
–tuple[plt.Figure, plt.Axes]: Figure and axes handles
Example: ```python
history = dict( loss=[0.1, 0.2, 0.3, 0.4], accuracy=[0.9, 0.8, 0.7, 0.6], val_loss=[0.1, 0.2, 0.3, 0.4], val_accuracy=[0.9, 0.8, 0.7, 0.6], )
fig, ax = nse.plotting.plot_history_metrics(history, metrics=["loss", "accuracy"], include_val=True, stack=False)