A plotter for reinforcement learning (RL)
Project description
rl-plotter
This is a simple tool which can plot learning curves easily for reinforcement learning (RL).
Installation
from PIP
pip install rl_plotter
from source
python setup.py install
Usage
Add our logger in your code of evaluation
from rl_plotter.logger import Logger
logger = Logger(exp_name="your_exp_name", env_name, seed)
路路路路
logger.update(score=evaluation_score_list, total_steps=current_training_steps)
or you can use OpenAI-baseline bench.Monitor:
env = logger.monitor_env(env)
if you want to track other variables:
custom_logger=logger.new_custom_logger(filename, fieldnames=["variable 1", "variable 2", ..., "variable n"])
custom_logger.update(fieldvalues=variable_value_list, total_steps=current_training_steps)
After the training or when you are training your agent, you can plot the learning curves in this way:
-
switch to log directory (default: ./)
-
run command to plot:
rl_plotter --save --show
more general commands in practice:
rl_plotter --save --show --avg_group --shaded_std
rl_plotter --save --show --avg_group --shaded_std --time
rl_plotter --save --show --avg_group --shaded_std --shaded_err
for help:
rl_plotter --help
and you can find parameters to custom the style of your curves.
optional arguments:
-h, --help show this help message and exit
--fig_length matplotlib figure length (default: 6)
--fig_width matplotlib figure width (default: 6)
--style matplotlib figure style (default: seaborn)
--title matplotlib figure title (default: None)
--xlabel matplotlib figure xlabel
--xkey x-axis key in csv file (default: l)
--ykey y-axis key in csv file (default: r)
--ylabel matplotlib figure ylabel
--smooth smooth radius of y axis (default: 10)
--resample if not zero, size of the uniform grid in x direction
to resample onto. Resampling is performed via
symmetric EMA smoothing (see the docstring for
symmetric_ema). Default is zero (no resampling). Note
that if average_group is True, resampling is
necessary; in that case, default value is 512.
(default: 512)
--smooth_step when resampling (i.e. when resample > 0 or
average_group is True), use this EMA decay parameter
(in units of the new grid step). See docstrings for
decay_steps in symmetric_ema or one_sided_ema functions.
(default: 1.0)
--avg_group average the curves in the same group and plot the mean
--shaded_std shaded region corresponding to standard deviation of the group
--shaded_err shaded region corresponding to error in mean estimate of the group
--legend_loc location of legend
--legend_outside place the legend outside of the figure
--no_legend_group_num don't show num of group in legend
--time enable this will set x_key to t, and activate parameters about time
--time_unit parameters about time, x axis time unit (default: h)
--time_interval parameters about time, x axis time interval (default: 1)
--xformat x-axis format
--xlim x-axis limitation (default: None)
--log_dir log dir (default: ./)
--filename csv filename
--show show figure
--save save figure
--dpi figure dpi (default: 400)
finally, the learning curves looks like this:
Features
- custom logger, style, key, label, interval, and so on ...
- multi-experiment plotter
- x-axis formatter features
- compatible with OpenAI-baseline monitor data style
- corresponding color for specific experiment
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
rl_plotter-2.2.3.tar.gz
(10.0 kB
view hashes)
Built Distribution
rl_plotter-2.2.3-py3-none-any.whl
(29.7 kB
view hashes)
Close
Hashes for rl_plotter-2.2.3-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 75c474d1a874386d25a4196f9702de9e1855f4a16220a81a4c1cf5258c4afb9e |
|
MD5 | 3b25ddba42f54e07b267fe7e46acd126 |
|
BLAKE2b-256 | 33dbcc201274a4fae681a4e7c16388d08986f8ba81ab7ab5c825f70719129901 |