:py:mod:`orcanet.utilities.visualization` ========================================= .. py:module:: orcanet.utilities.visualization .. autoapi-nested-parse:: Visualization tools used without Keras. Makes performance graphs for training and validating. .. !! processed by numpydoc !! Module Contents --------------- Classes ~~~~~~~ .. autoapisummary:: orcanet.utilities.visualization.TrainValPlotter Functions ~~~~~~~~~ .. autoapisummary:: orcanet.utilities.visualization.gaussian_smooth orcanet.utilities.visualization.plot_history orcanet.utilities.visualization.skip_nans orcanet.utilities.visualization.get_ylims orcanet.utilities.visualization.get_epoch_xticks orcanet.utilities.visualization.update_summary_plot orcanet.utilities.visualization.sort_metrics .. py:class:: TrainValPlotter Class for plotting train/val curves. .. !! processed by numpydoc !! .. py:method:: 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) Plot a training and optionally a validation line. The data can contain nan's. :Parameters: **train_data** : List X data [0] and y data [1] of the train curve. Will be plotted as connected dots. **val_data** : List, 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_label** : str, optional Label for the train line in the legend. **val_label** : str, optional Label for the validation line in the legend. **color** : str, optional Color used for the train/val line. **smooth_sigma** : int, optional Apply gaussian blur to the train curve with given sigma. **tlw** : float Linewidth of train curve. **vlw** : float Linewidth of val curve. **vms** : float Markersize of the val curve. .. !! processed by numpydoc !! .. py:method:: 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) Apply given layout. Can calculate good y_lims and x_ticks automatically. :Parameters: **title** : str Title of the plot. **x_label** : str X label of the plot. **y_label** : str Y label of the plot. **grid** : bool If true, show a grid. **legend** : bool If true, show a legend. **x_lims** : List X limits of the data. **y_lims** : List or str Y limits of the data. "auto" for auto-calculation. **x_ticks** : List Positions of the major x ticks. **logy** : bool If true, make y axis log. .. !! processed by numpydoc !! .. py:function:: gaussian_smooth(y, sigma, truncate=4) Smooth a 1d ndarray with a gaussian filter. .. !! processed by numpydoc !! .. py:function:: plot_history(train_data, val_data=None, train_label='training', val_label='validation', color=None, **kwargs) Plot the train/val curves in a single plot. For backward compat. Functionality moved to TrainValPlotter .. !! processed by numpydoc !! .. py:function:: skip_nans(data) Skip over nan values, so that all dots are connected. :Parameters: **data** : List Contains x and y data as ndarrays. The y values may contain nans. :Returns: **data_clean** : List Contains x and y data as ndarrays. Points with y=nan are skipped. .. !! processed by numpydoc !! .. py:function:: get_ylims(y_points_train, y_points_val=None, fraction=0.25) 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_train** : List y data of the train curve. **y_points_val** : List or None Y data of the validation curve. **fraction** : float or List How much whitespace of the total y range is added below and above the lines. :Returns: **y_lims** : tuple Minimum, maximum of the data. .. !! processed by numpydoc !! .. py:function:: get_epoch_xticks(x_points) Calculates the xticks for the train and validation summary plot. One tick per epoch. Less the larger #epochs is. :Parameters: **x_points** : List A list of the x coordinates of all points. :Returns: **x_ticks_major** : numpy.ndarray Array containing the ticks. .. !! processed by numpydoc !! .. py:function:: update_summary_plot(orga) 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: **orga** : orcanet.core.Organizer Contains all the configurable options in the OrcaNet scripts. .. !! processed by numpydoc !! .. py:function:: sort_metrics(metric_names) 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_names** : List List of metric names. :Returns: **sorted_metrics** : List List of sorted metric names with the same length as the input. .. !! processed by numpydoc !!