noggin.plotter.LivePlot

class noggin.plotter.LivePlot(metrics: Union[str, Sequence[str], Dict[str, Union[str, numbers.Real, Sequence[numbers.Real], None]], Dict[str, Dict[str, Union[str, numbers.Real, Sequence[numbers.Real], None]]]], max_fraction_spent_plotting: float = 0.05, last_n_batches: Optional[int] = None, nrows: Optional[int] = None, ncols: int = 1, figsize: Optional[Tuple[int, int]] = None)[source]

Records and plots batch-level and epoch-level summary statistics of the training and testing metrics of a model during a session.

The rate at which the plot is updated is controlled by max_fraction_spent_plotting.

The maximum number of batches to be included in the plot is controlled by last_n_batches.

Notes

Live plotting is only supported for the ‘nbAgg’ backend (i.e. when the cell magic %matplotlib notebook is invoked in a jupyter notebook).

Attributes:
figsize

Returns the current size of the figure in inches.

last_n_batches

The maximum number of batches to be plotted at any given time.

max_fraction_spent_plotting

The maximum fraction of time spent plotting.

metric_colors

The color associated with each of the train/test and batch/epoch-level metrics.

metrics

A tuple of all the metric names

plot_objects

The figure-instance of the plot, and the axis-instance for each metric.

test_metrics

The batch and epoch data for each test-metric.

train_metrics

The batch and epoch data for each train-metric.

Methods

from_dict(plotter_dict) Records the state of the plotter in a dictionary.
plot(plot_batches) Plot the logged data.
set_test_batch(metrics, numbers.Real], …) Record batch-level measurements for test-metrics.
set_test_epoch() Record and plot an epoch for the test-metrics.
set_train_batch(metrics, numbers.Real], …) Record batch-level measurements for train-metrics, and (optionally) plot them.
set_train_epoch() Record and plot an epoch for the train-metrics.
show() Calls matplotlib.pyplot.show().
to_dict() Records the state of the plotter in a dictionary.
to_xarray(train_or_test) Returns xarray datasets for the batch-level and epoch-level metrics, respectively, for either the train-metrics or test-metrics.
__init__(metrics: Union[str, Sequence[str], Dict[str, Union[str, numbers.Real, Sequence[numbers.Real], None]], Dict[str, Dict[str, Union[str, numbers.Real, Sequence[numbers.Real], None]]]], max_fraction_spent_plotting: float = 0.05, last_n_batches: Optional[int] = None, nrows: Optional[int] = None, ncols: int = 1, figsize: Optional[Tuple[int, int]] = None)[source]
Parameters:
metrics : Union[str, Sequence[str], Dict[str, valid-color], Dict[str, Dict[‘train’/’test’, valid-color]]]

The name, or sequence of names, of the metric(s) that will be plotted.

metrics can also be a dictionary, specifying the colors used to plot the metrics. Two mappings are valid:

  • ‘<metric-name>’ -> color-value (specifies train-metric color only)
  • ‘<metric-name>’ -> {‘train’/’test’ : color-value}
max_fraction_spent_plotting : float, optional (default=0.05)

The maximum fraction of time spent plotting. The default value is 0.5, meaning that no more than 5% of processing time will be spent plotting, on average.

last_n_batches : Optional[int]

The maximum number of batches to be plotted at any given time. If None, all data will be plotted.

nrows : Optional[int]

Number of rows of the subplot grid. Metrics are added in row-major order to fill the grid.

ncols : int, optional, default: 1

Number of columns of the subplot grid. Metrics are added in row-major order to fill the grid.

figsize : Optional[Sequence[float, float]]

Specifies the width and height, respectively, of the figure.

Methods

__init__(metrics, Sequence[str], Dict[str, …)
Parameters:
from_dict(plotter_dict) Records the state of the plotter in a dictionary.
plot(plot_batches) Plot the logged data.
set_test_batch(metrics, numbers.Real], …) Record batch-level measurements for test-metrics.
set_test_epoch() Record and plot an epoch for the test-metrics.
set_train_batch(metrics, numbers.Real], …) Record batch-level measurements for train-metrics, and (optionally) plot them.
set_train_epoch() Record and plot an epoch for the train-metrics.
show() Calls matplotlib.pyplot.show().
to_dict() Records the state of the plotter in a dictionary.
to_xarray(train_or_test) Returns xarray datasets for the batch-level and epoch-level metrics, respectively, for either the train-metrics or test-metrics.

Attributes

figsize Returns the current size of the figure in inches.
last_n_batches The maximum number of batches to be plotted at any given time.
max_fraction_spent_plotting The maximum fraction of time spent plotting.
metric_colors The color associated with each of the train/test and batch/epoch-level metrics.
metrics A tuple of all the metric names
plot_objects The figure-instance of the plot, and the axis-instance for each metric.
test_metrics The batch and epoch data for each test-metric.
train_metrics The batch and epoch data for each train-metric.