ray.tune.ExperimentAnalysis#

class ray.tune.ExperimentAnalysis(experiment_checkpoint_path: str, trials: Optional[List[ray.tune.experiment.trial.Trial]] = None, default_metric: Optional[str] = None, default_mode: Optional[str] = None, remote_storage_path: Optional[str] = None, sync_config: Optional[ray.tune.syncer.SyncConfig] = None)[source]#

Bases: object

Analyze results from a Tune experiment.

To use this class, the experiment must be executed with the JsonLogger.

Parameters
  • experiment_checkpoint_path – Path to a json file or directory representing an experiment state, or a directory containing multiple experiment states (a run’s local_dir). Corresponds to Experiment.local_dir/Experiment.name/ experiment_state.json

  • trials – List of trials that can be accessed via analysis.trials.

  • default_metric – Default metric for comparing results. Can be overwritten with the metric parameter in the respective functions.

  • default_mode – Default mode for comparing results. Has to be one of [min, max]. Can be overwritten with the mode parameter in the respective functions.

Example

>>> from ray import tune
>>> tune.run( 
...     my_trainable, name="my_exp", local_dir="~/tune_results")
>>> analysis = ExperimentAnalysis( 
...     experiment_checkpoint_path="~/tune_results/my_exp/state.json")

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

Methods

dataframe([metric, mode])

Returns a pandas.DataFrame object constructed from the trials.

fetch_trial_dataframes()

Fetches trial dataframes from files.

get_all_configs([prefix])

Returns a list of all configurations.

get_best_checkpoint(trial[, metric, mode, ...])

Gets best persistent checkpoint path of provided trial.

get_best_config([metric, mode, scope])

Retrieve the best config corresponding to the trial.

get_best_logdir([metric, mode, scope])

Retrieve the logdir corresponding to the best trial.

get_best_trial([metric, mode, scope, ...])

Retrieve the best trial object.

get_last_checkpoint([trial, metric, mode])

Gets the last persistent checkpoint path of the provided trial, i.e., with the highest "training_iteration".

get_trial_checkpoints_paths(trial[, metric])

Gets paths and metrics of all persistent checkpoints of a trial.

runner_data()

Returns a dictionary of the TuneController data.

set_filetype([file_type])

Overrides the existing file type.

stats()

Returns a dictionary of the statistics of the experiment.

Attributes

best_checkpoint

Get the checkpoint path of the best trial of the experiment

best_config

Get the config of the best trial of the experiment

best_dataframe

Get the full result dataframe of the best trial of the experiment

best_logdir

Get the logdir of the best trial of the experiment

best_result

Get the last result of the best trial of the experiment

best_result_df

Get the best result of the experiment as a pandas dataframe.

best_trial

Get the best trial of the experiment

experiment_path

Path pointing to the experiment directory on persistent storage.

results

Get the last result of the all trials of the experiment

results_df

Get all the last results as a pandas dataframe.

trial_dataframes

List of all dataframes of the trials.