ray.train.Result#

class ray.train.Result(metrics: Dict[str, Any] | None, checkpoint: Checkpoint | None, error: Exception | None, path: str, metrics_dataframe: pd.DataFrame | None = None, best_checkpoints: List[Tuple[Checkpoint, Dict[str, Any]]] | None = None, _storage_filesystem: pyarrow.fs.FileSystem | None = None)#

The final result of a ML training run or a Tune trial.

This is the output produced by Trainer.fit. Tuner.fit outputs a ResultGrid that is a collection of Result objects.

This API is the recommended way to access the outputs such as: - checkpoints (Result.checkpoint) - the history of reported metrics (Result.metrics_dataframe, Result.metrics) - errors encountered during a training run (Result.error)

The constructor is a private API – use Result.from_path to create a result object from a directory.

metrics#

The latest set of reported metrics.

Type:

Dict[str, Any] | None

checkpoint#

The latest checkpoint.

Type:

Checkpoint | None

error#

The execution error of the Trainable run, if the trial finishes in error.

Type:

Exception | None

path#

Path pointing to the result directory on persistent storage. This can point to a remote storage location (e.g. S3) or to a local location (path on the head node). The path is accessible via the result’s associated filesystem. For instance, for a result stored in S3 at s3://bucket/location, path will have the value bucket/location.

Type:

str

metrics_dataframe#

The full result dataframe of the Trainable. The dataframe is indexed by iterations and contains reported metrics. Note that the dataframe columns are indexed with the flattened keys of reported metrics, so the format of this dataframe may be slightly different than Result.metrics, which is an unflattened dict of the latest set of reported metrics.

Type:

pd.DataFrame | None

best_checkpoints#

A list of tuples of the best checkpoints and their associated metrics. The number of saved checkpoints is determined by CheckpointConfig (by default, all checkpoints will be saved).

Type:

List[Tuple[Checkpoint, Dict[str, Any]]] | None

property config: Dict[str, Any] | None#

The config associated with the result.

property filesystem: pyarrow.fs.FileSystem#

Return the filesystem that can be used to access the result path.

Returns:

pyarrow.fs.FileSystem implementation.

classmethod from_path(path: str | PathLike, storage_filesystem: pyarrow.fs.FileSystem | None = None) Result[source]#

Restore a Result object from local or remote trial directory.

Parameters:
  • path – A path of a trial directory on local or remote storage (ex: s3://bucket/path or /tmp/ray_results).

  • storage_filesystem – A custom filesystem to use. If not provided, this will be auto-resolved by pyarrow. If provided, the path is assumed to be prefix-stripped already, and must be a valid path on the filesystem.

Returns:

A Result object of that trial.

get_best_checkpoint(metric: str, mode: str) Checkpoint | None[source]#

Get the best checkpoint from this trial based on a specific metric.

Any checkpoints without an associated metric value will be filtered out.

Parameters:
  • metric – The key for checkpoints to order on.

  • mode – One of [“min”, “max”].

Returns:

Checkpoint object, or None if there is no valid checkpoint associated with the metric.

PublicAPI (alpha): This API is in alpha and may change before becoming stable.