rlberry API

Manager

Main classes

manager.ExperimentManager(agent_class[, ...])

Class to train, optimize hyperparameters, evaluate and gather statistics about an agent.

manager.MultipleManagers([max_workers, ...])

Class to fit multiple ExperimentManager instances in parallel with multiple threads.

Evaluation and plot

manager.AdastopComparator([n, K, B, ...])

Compare sequentially agents, with possible early stopping.

manager.evaluate_agents(experiment_manager_list)

Evaluate and compare each of the agents in experiment_manager_list.

manager.read_writer_data(data_source[, ...])

Given a list of ExperimentManager or a folder, read data (corresponding to info) obtained in each episode.

manager.plot_writer_data(data_source, tag[, ...])

Given a list of ExperimentManager or a folder, plot data (corresponding to info) obtained in each episode.

manager.plot_smoothed_curves(data, x, y[, ...])

Plot the performances contained in the data (see data parameter to learn what format it should be).

manager.plot_synchronized_curves(data, x, y)

Plot the performances contained in the data (see data parameter to learn what format it should be).

manager.compare_agents(agent_source[, ...])

Compare several trained agents using the mean over n_simulations evaluations for each agent.

Agents

Base classes

agents.Agent([env, eval_env, copy_env, ...])

Basic interface for agents.

agents.AgentWithSimplePolicy([env, ...])

Interface for agents whose policy is a function of observations only.

Agent importation tools

agents.stable_baselines.StableBaselinesAgent(env)

Wraps an StableBaselines3 Algorithm with a rlberry Agent.

Environments

Base class

envs.interface.Model()

Base class for an environment model.

envs.basewrapper.Wrapper(env[, wrap_spaces])

Wraps a given environment, similar to OpenAI gym's wrapper [1,2] (now updated to gymnasium).

Spaces

spaces.Discrete(n)

Class that represents discrete spaces.

spaces.Box(low, high[, shape, dtype])

Class that represents a space that is a cartesian product in R^n:

spaces.Tuple(spaces)

Inherited from gymnasium.spaces.Tuple for compatibility with gym.

spaces.MultiDiscrete(nvec[, dtype])

Inherited from gymnasium.spaces.MultiDiscrete for compatibility with gym.

spaces.MultiBinary(n)

Inherited from gymnasium.spaces.MultiBinary for compatibility with gym.

spaces.Dict([spaces])

Inherited from gymnasium.spaces.Dict for compatibility with gym.

Environment tools

envs.gym_make(id[, wrap_spaces])

Same as gym.make, but wraps the environment to ensure unified seeding with rlberry.

envs.atari_make(id[, seed])

Adaptor to manage Atari Env

envs.PipelineEnv(env_ctor, env_kwargs, wrappers)

Environment defined as a pipeline of wrappers and an environment to wrap.

Seeding

seeding.seeder.Seeder([seed_seq, spawn_seed_seq])

Base class to define objects that use random number generators.

seeding.safe_reseed(obj, seeder[, reseed_spaces])

Calls obj.reseed(seed_seq) method if available; If a obj.seed() method is available, call obj.seed(seed_val), where seed_val is generated by the seeder.

seeding.set_external_seed(seeder)

Set seeds of external libraries.

Utilities, Logging & Typing

Manager Utilitis

manager.preset_manager(*args, **kwds)

Preset an ExperimentManager to some fixed keywords.

Virtual environment Utilities

manager.with_venv([import_libs, ...])

Decorator to run the script in a function using a virtual environment.

manager.run_venv_xp([venv_dir_name, verbose])

Function to launch experiments in the current script file in virtual environments.

Writer Utilities

utils.writers.DefaultWriter(name[, ...])

Default writer to be used by the agents, optionally wraps an instance of tensorboard.SummaryWriter.

agents.utils.replay.ReplayBuffer(...[, ...])

Replay buffer that allows sampling data with shape (batch_size, time_size, ...).

Check Utilities

utils.check_rl_agent(agent[, env, init_kwargs])

Check ExperimentManager compatibility and check reproducibility/seeding.

utils.check_env(env)

Check that the environment is (almost) gym-compatible and that it is reproducible in the sense that it returns the same states when given the same seed.

utils.check_save_load(agent[, env, init_kwargs])

utils.check_fit_additive(agent[, env, ...])

Check that fitting two times with 10 fit budget is the same as fitting one time with 20 fit budget.

utils.check_seeding_agent(agent[, env, ...])

Check that the agent is reproducible.

utils.check_experiment_manager(agent[, env, ...])

Check that the agent is compatible with ExperimentManager.

Logging Utilities

utils.logging.set_level([level])

Set rlberry's logger level.

Environment Wrappers

wrappers.discretize_state.DiscretizeStateWrapper(...)

Discretize an environment with continuous states and discrete actions.

wrappers.gym_utils.OldGymCompatibilityWrapper(env)

Allow to use old gym env (V0.21) with rlberry (gymnasium).

wrappers.RescaleRewardWrapper(env, reward_range)

Rescale the reward function to a bounded range.