stable_learning_control.utils.plot

Module used for plotting the training results.

Note

This module was based on Spinning Up repository.

Attributes

DIV_LINE_WIDTH

VALID_DATA_FILES

exp_idx

units

Functions

plot_data(data[, xaxis, value, condition, errorbar, ...])

Function used to plot data.

get_datasets(logdir[, condition])

Recursively look through logdir for output files produced by

get_all_datasets(all_logdirs[, legend, select, exclude])

For every entry in all_logdirs,

make_plots(all_logdirs[, legend, xaxis, values, ...])

Function used for generating the plots.

plot()

Run the plot utility.

Module Contents

stable_learning_control.utils.plot.DIV_LINE_WIDTH = 50[source]
stable_learning_control.utils.plot.VALID_DATA_FILES = ['progress.txt', 'progress.csv'][source]
stable_learning_control.utils.plot.exp_idx = 0[source]
stable_learning_control.utils.plot.units[source]
stable_learning_control.utils.plot.plot_data(data, xaxis='Epoch', value='AverageEpRet', condition='Condition1', errorbar='sd', smooth=1, font_scale=1.5, style='darkgrid', **kwargs)[source]

Function used to plot data.

Parameters:
  • data (obj) – The data you want to plot.

  • xaxis (str) – Pick what column from data is used for the x-axis. Defaults to TotalEnvInteracts.

  • value (str) – Pick what columns from data to graph on the y-axis. Submitting multiple values will produce multiple graphs. Defaults to Performance, which is not an actual output of any algorithm. Instead, Performance refers to either AverageEpRet, the correct performance measure for the on-policy algorithms, or AverageTestEpRet, the correct performance measure for the off-policy algorithms. The plotter will automatically figure out which of AverageEpRet or AverageTestEpRet to report for each separate logdir.

  • condition (str, optional) – The condition to search for. By default Condition1.

  • errorbar (str) – The error bar you want to use for the plot. Defaults to sd.

  • smooth (int) – Smooth data by averaging it over a fixed window. This parameter says how wide the averaging window will be.

  • font_scale (int) – The font scale you want to use for the plot text.

  • style (str) – The style you want to use for the plot.

stable_learning_control.utils.plot.get_datasets(logdir, condition=None)[source]

Recursively look through logdir for output files produced by EpochLogger.

Assumes that any file progress.(csv|txt) is a valid hit.

Parameters:
  • logdir (str) – The log directory to search in.

  • condition (str, optional) – The condition to search for. By default None.

stable_learning_control.utils.plot.get_all_datasets(all_logdirs, legend=None, select=None, exclude=None)[source]
For every entry in all_logdirs,
  1. check if the entry is a real directory and if it is, pull data from it;

  2. if not, check to see if the entry is a prefix for a real directory, and pull data from that.

Parameters:
  • all_logdirs (list) – A list of lig directories you want to use.

  • legend (list[str]) – Optional way to specify legend for the plot. The plotter legend will automatically use the exp_name from the config.json file, unless you tell it otherwise through this flag. This only works if you provide a name for each directory that will get plotted. (Note: this may not be the same as the number of logdir args you provide! Recall that the plotter looks for autocompletes of the logdir args: there may be more than one match for a given logdir prefix, and you will need to provide a legend string for each one of those matches—unless you have removed some of them as candidates via selection or exclusion rules (below).)

  • select (list[str]) – Optional selection rule: the plotter will only show curves from logdirs that contain all of these substrings.

  • exclude (list[str]) – Optional exclusion rule: plotter will only show curves from logdirs that do not contain these substrings.

stable_learning_control.utils.plot.make_plots(all_logdirs, legend=None, xaxis=None, values=None, count=False, font_scale=1.5, style='darkgrid', smooth=1, select=None, exclude=None, estimator='mean')[source]

Function used for generating the plots.

Parameters:
  • logdir (str) – As many log directories (or prefixes to log directories, which the plotter will autocomplete internally) as you’d like to plot from.

  • legend (list[str]) – Optional way to specify legend for the plot. The plotter legend will automatically use the exp_name from the config.json file, unless you tell it otherwise through this flag. This only works if you provide a name for each directory that will get plotted. (Note: this may not be the same as the number of logdir args you provide! Recall that the plotter looks for autocompletes of the logdir args: there may be more than one match for a given logdir prefix, and you will need to provide a legend string for each one of those matches—unless you have removed some of them as candidates via selection or exclusion rules (below).)

  • xaxis (str) – Pick what column from data is used for the x-axis. Defaults to TotalEnvInteracts.

  • values (list) – Pick what columns from data to graph on the y-axis. Submitting multiple values will produce multiple graphs. Defaults to Performance, which is not an actual output of any algorithm. Instead, Performance refers to either AverageEpRet, the correct performance measure for the on-policy algorithms, or AverageTestEpRet, the correct performance measure for the off-policy algorithms. The plotter will automatically figure out which of AverageEpRet or AverageTestEpRet to report for each separate logdir.

  • count – Optional flag. By default, the plotter shows y-values which are averaged across all results that share an exp_name, which is typically a set of identical experiments that only vary in random seed. But if you’d like to see all of those curves separately, use the --count flag.

  • font_scale (int) – The font scale you want to use for the plot text.

  • style (str) – The style you want to use for the plot.

  • smooth (int) – Smooth data by averaging it over a fixed window. This parameter says how wide the averaging window will be.

  • select (list[str]) – Optional selection rule: the plotter will only show curves from logdirs that contain all of these substrings.

  • exclude (list[str]) – Optional exclusion rule: plotter will only show curves from logdirs that do not contain these substrings.

  • estimator (str) – The estimator you want to use in your plot (ie. mean, min max).

stable_learning_control.utils.plot.plot()[source]

Run the plot utility.

Parameters:
  • logdir (list[str]) – As many log directories (or prefixes to log directories, which the plotter will autocomplete internally) as you’d like to plot from.

  • legend (list[str]) – Optional way to specify legend for the plot. The plotter legend will automatically use the exp_name from the config.json file, unless you tell it otherwise through this flag. This only works if you provide a name for each directory that will get plotted. (Note: this may not be the same as the number of logdir args you provide! Recall that the plotter looks for autocompletes of the logdir args: there may be more than one match for a given logdir prefix, and you will need to provide a legend string for each one of those matches—unless you have removed some of them as candidates via selection or exclusion rules (below).)

  • xaxis (str) – Pick what column from data is used for the x-axis. Defaults to TotalEnvInteracts.

  • value (str) – Pick what columns from data to graph on the y-axis. Submitting multiple values will produce multiple graphs. Defaults to Performance, which is not an actual output of any algorithm. Instead, Performance refers to either AverageEpRet, the correct performance measure for the on-policy algorithms, or AverageTestEpRet, the correct performance measure for the off-policy algorithms. The plotter will automatically figure out which of AverageEpRet or AverageTestEpRet to report for each separate logdir.

  • count – Optional flag. By default, the plotter shows y-values which are averaged across all results that share an exp_name, which is typically a set of identical experiments that only vary in random seed. But if you’d like to see all of those curves separately, use the --count flag.

  • smooth (int) – Smooth data by averaging it over a fixed window. This parameter says how wide the averaging window will be.

  • select (list[str]) – Optional selection rule: the plotter will only show curves from logdirs that contain all of these substrings.

  • exclude (list[str]) – Optional exclusion rule: plotter will only show curves from logdirs that do not contain these substrings.