bff.plot.plot_history

bff.plot.plot_history(history, metric=None, twinx=False, title='Model history', axes=None, loc='best', grid=None, figsize=12, 7, dpi=80, style='default', **kwargs)

Plot the history of the model trained using Keras.

Parameters
  • history (dict) – Dictionary from the history object of the training.

  • metric (str, optional) – Metric to plot. If no metric is provided, will only print the loss.

  • twinx (bool, default False) – If metric and twinx, plot the loss and the metric on the same axis. Four colors will be used for the plot.

  • title (str, default 'Model history') – Main title for the plot (figure level).

  • axes (plt.axes, optional) – Axes from matplotlib, if None, new figure and axes will be created. If metric is provided, need to have at least 2 axes.

  • loc (str or int, default 'best') – Location of the legend on the plot. Either the legend string or legend code are possible.

  • grid (str, optional) – Axis where to activate the grid (‘both’, ‘x’, ‘y’). To turn off, set to None.

  • figsize (Tuple[int, int], default (12, 7)) – Size of the figure to plot.

  • dpi (int, default 80) – Resolution of the figure.

  • style (str, default 'default') – Style to use for matplotlib.pyplot. The style is use only in this context and not applied globally.

  • **kwargs – Additional keyword arguments to be passed to the plt.plot function from matplotlib.

Returns

Axes object or array of Axes objects returned by the plt.subplots function.

Return type

plt.axes

Examples

>>> history = model.fit(...)
>>> plot_history(history.history, metric='acc', title='MyTitle', linestyle=':')