class minari.MinariDataset(data: MinariStorage | str | PathLike, episode_indices: ndarray | None = None)[source]#

Main Minari dataset class to sample data and get metadata information from a dataset.

Initialize properties of the Minari Dataset.

  • data (Union[MinariStorage, PathLike]) – source of data.

  • episode_indices (Optional[np.ndarray]) – slice of episode indices this dataset is pointing to.


minari.MinariDataset.sample_episodes(self, n_episodes: int) Iterable[EpisodeData]#

Sample n number of episodes from the dataset.


n_episodes (Optional[int], optional) – number of episodes to sample.

minari.MinariDataset.iterate_episodes(self, episode_indices: List[int] | None = None) Iterator[EpisodeData]#

Iterate over episodes from the dataset.


episode_indices (Optional[List[int]], optional) – episode indices to iterate over.

minari.MinariDataset.filter_episodes(self, condition: Callable[[EpisodeData], bool]) MinariDataset#

Filter the dataset episodes with a condition.

The condition must be a callable which takes an EpisodeData instance and retutrns a bool. The callable must return a bool True if the condition is met and False otherwise. i.e filtering for episodes that terminate:

` dataset.filter(condition=lambda x: x['terminations'][-1] ) `


condition (Callable[[EpisodeData], bool]) – function that gets in input an EpisodeData object and returns True if certain condition is met.

minari.MinariDataset.set_seed(self, seed: int)#

Set seed for random episode sampling generator.

minari.MinariDataset.recover_environment(self, eval_env: bool = False, **kwargs) Env#

Recover the Gymnasium environment used to create the dataset.

  • eval_env (bool) – if True the returned Gymnasium environment will be that intended to be used for evaluation. If no eval_env was specified when creating the dataset, the returned environment will be the same as the one used for creating the dataset. Default False.

  • **kwargs – any other parameter that you want to pass to the gym.make function.


environment – Gymnasium environment

minari.MinariDataset.update_dataset_from_buffer(self, buffer: List[dict])#

Additional data can be added to the Minari Dataset from a list of episode dictionary buffers.

Each episode dictionary buffer must have the following items:
  • observations: np.ndarray of step observations. shape = (total_episode_steps + 1, (observation_shape)). Should include initial and final observation

  • actions: np.ndarray of step action. shape = (total_episode_steps + 1, (action_shape)).

  • rewards: np.ndarray of step rewards. shape = (total_episode_steps + 1, 1).

  • terminations: np.ndarray of step terminations. shape = (total_episode_steps + 1, 1).

  • truncations: np.ndarray of step truncations. shape = (total_episode_steps + 1, 1).

Other additional items can be added as long as the values are np.ndarray’s or other nested dictionaries.


buffer (list[dict]) – list of episode dictionary buffers to add to dataset



Total episodes steps in the Minari dataset.


Indices of the available episodes to sample within the Minari dataset.