orcanet.utilities.visualization
Visualization tools used without Keras. Makes performance graphs for training and validating.
Module Contents
Classes
Class for plotting train/val curves. |
Functions
|
Smooth a 1d ndarray with a gaussian filter. |
|
Plot the train/val curves in a single plot. |
|
Skip over nan values, so that all dots are connected. |
|
Get the y limits for the summary plot. |
|
Calculates the xticks for the train and validation summary plot. |
|
Plot and save all metrics of the given validation- and train-data |
|
Sort a list of metrics, so that errors are right after their variable. |
- class orcanet.utilities.visualization.TrainValPlotter[source]
Class for plotting train/val curves.
- plot_curves(train_data, val_data=None, train_label='training', val_label='validation', color=None, smooth_sigma=None, tlw=0.5, vlw=0.5, vms=3)[source]
Plot a training and optionally a validation line.
The data can contain nan’s.
- Parameters
- train_dataList
X data [0] and y data [1] of the train curve. Will be plotted as connected dots.
- val_dataList, optional
Optional X data [0] and y data [1] of the validation curve. Will be plotted as a faint solid line of the same color as train.
- train_labelstr, optional
Label for the train line in the legend.
- val_labelstr, optional
Label for the validation line in the legend.
- colorstr, optional
Color used for the train/val line.
- smooth_sigmaint, optional
Apply gaussian blur to the train curve with given sigma.
- tlwfloat
Linewidth of train curve.
- vlwfloat
Linewidth of val curve.
- vmsfloat
Markersize of the val curve.
- apply_layout(title=None, x_label='Epoch', y_label=None, grid=True, legend=True, x_lims=None, y_lims='auto', x_ticks='auto', logy=False)[source]
Apply given layout. Can calculate good y_lims and x_ticks automatically.
- Parameters
- titlestr
Title of the plot.
- x_labelstr
X label of the plot.
- y_labelstr
Y label of the plot.
- gridbool
If true, show a grid.
- legendbool
If true, show a legend.
- x_limsList
X limits of the data.
- y_limsList or str
Y limits of the data. “auto” for auto-calculation.
- x_ticksList
Positions of the major x ticks.
- logybool
If true, make y axis log.
- orcanet.utilities.visualization.gaussian_smooth(y, sigma, truncate=4)[source]
Smooth a 1d ndarray with a gaussian filter.
- orcanet.utilities.visualization.plot_history(train_data, val_data=None, train_label='training', val_label='validation', color=None, **kwargs)[source]
Plot the train/val curves in a single plot.
For backward compat. Functionality moved to TrainValPlotter
- orcanet.utilities.visualization.skip_nans(data)[source]
Skip over nan values, so that all dots are connected.
- Parameters
- dataList
Contains x and y data as ndarrays. The y values may contain nans.
- Returns
- data_cleanList
Contains x and y data as ndarrays. Points with y=nan are skipped.
- orcanet.utilities.visualization.get_ylims(y_points_train, y_points_val=None, fraction=0.25)[source]
Get the y limits for the summary plot.
For the training data, limits are calculated while ignoring data points which are far from the median (in terms of the median distance from the median). This is because there are outliers sometimes in the training data, especially early on in the training.
- Parameters
- y_points_trainList
y data of the train curve.
- y_points_valList or None
Y data of the validation curve.
- fractionfloat or List
How much whitespace of the total y range is added below and above the lines.
- Returns
- y_limstuple
Minimum, maximum of the data.
- orcanet.utilities.visualization.get_epoch_xticks(x_points)[source]
Calculates the xticks for the train and validation summary plot.
One tick per epoch. Less the larger #epochs is.
- Parameters
- x_pointsList
A list of the x coordinates of all points.
- Returns
- x_ticks_majornumpy.ndarray
Array containing the ticks.
- orcanet.utilities.visualization.update_summary_plot(orga)[source]
Plot and save all metrics of the given validation- and train-data into a pdf file, each metric in its own plot.
If metric pairs of a variable and its error are found (e.g. e_loss and e_err_loss), they will have the same color and appear back to back in the plot.
- Parameters
- orgaorcanet.core.Organizer
Contains all the configurable options in the OrcaNet scripts.
- orcanet.utilities.visualization.sort_metrics(metric_names)[source]
Sort a list of metrics, so that errors are right after their variable. The format of the metric names have to be e.g. e_loss and e_err_loss for this to work.
- Parameters
- metric_namesList
List of metric names.
- Returns
- sorted_metricsList
List of sorted metric names with the same length as the input.