lit_sb3.core.results_plotter
source module lit_sb3.core.results_plotter
Functions
-
rolling_window — Apply a rolling window to a np.ndarray.
-
window_func — Apply a function to the rolling window of 2 arrays.
-
ts2xy — Decompose a data frame variable to x and ys.
-
plot_curves — Plot the curves.
-
plot_results — Plot the results using csv files from
Monitorwrapper.
source rolling_window(array: np.ndarray, window: int) → np.ndarray
Apply a rolling window to a np.ndarray.
Parameters
-
array : np.ndarray — the input Array
-
window : int — length of the rolling window
Returns
-
np.ndarray — rolling window on the input array
source window_func(var_1: np.ndarray, var_2: np.ndarray, window: int, func: Callable) → tuple[np.ndarray, np.ndarray]
Apply a function to the rolling window of 2 arrays.
Parameters
-
var_1 : np.ndarray — variable 1
-
var_2 : np.ndarray — variable 2
-
window : int — length of the rolling window
-
func : Callable — function to apply on the rolling window on variable 2 (such as np.mean)
Returns
-
tuple[np.ndarray, np.ndarray] — the rolling output with applied function
source ts2xy(data_frame: pd.DataFrame, x_axis: str) → tuple[np.ndarray, np.ndarray]
Decompose a data frame variable to x and ys.
(y = episodic return).
Parameters
-
data_frame : pd.DataFrame — the input data
-
x_axis : str — the x-axis for the x and y output (can be X_TIMESTEPS='timesteps', X_EPISODES='episodes' or X_WALLTIME='walltime_hrs')
Returns
-
tuple[np.ndarray, np.ndarray] — the x and y output
Raises
-
NotImplementedError
source plot_curves(xy_list: list[tuple[np.ndarray, np.ndarray]], x_axis: str, title: str, figsize: tuple[int, int] = (8, 2)) → None
Plot the curves.
Parameters
-
xy_list : list[tuple[np.ndarray, np.ndarray]] — the x and y coordinates to plot
-
x_axis : str — the axis for the x and y output (can be X_TIMESTEPS='timesteps', X_EPISODES='episodes' or X_WALLTIME='walltime_hrs')
-
title : str — the title of the plot
-
figsize : tuple[int, int] — Size of the figure (width, height)
source plot_results(dirs: list[str], num_timesteps: int | None, x_axis: str, task_name: str, figsize: tuple[int, int] = (8, 2)) → None
Plot the results using csv files from Monitor wrapper.
Parameters
-
dirs : list[str] — the save location of the results to plot
-
num_timesteps : int | None — only plot the points below this value
-
x_axis : str — the axis for the x and y output (can be X_TIMESTEPS='timesteps', X_EPISODES='episodes' or X_WALLTIME='walltime_hrs')
-
task_name : str — the title of the task to plot
-
figsize : tuple[int, int] — Size of the figure (width, height)