MinariDataset

minari.MinariDataset

class minari.MinariDataset(data: MinariStorage | PathLike, episode_indices: npt.NDArray[np.int_] | None = None)[source]

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

Initialize properties of the Minari Dataset.

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

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

Methods

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

Sample n number of episodes from the dataset.

Parameters:

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

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

Iterate over episodes from the dataset.

Parameters:

episode_indices (Optional[Iterable[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 returns 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] ) `

Parameters:

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.

Parameters:
  • 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.

Returns:

environment – Gymnasium environment

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

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

Parameters:

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

Attributes

MinariDataset.spec

Minari dataset specifier.

MinariDataset.total_steps

Total episodes steps in the Minari dataset.

MinariDataset.total_episodes

Total number of episodes in the Minari dataset.

MinariDataset.episode_indices

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