From bbd13ddc3361bbdd15fa93fe6ef4f30eec68b5c0 Mon Sep 17 00:00:00 2001 From: Kai Fricke Date: Sat, 27 Aug 2022 02:01:57 -0700 Subject: [PATCH] [air/docs] Add example to fetch results dataframe for trainer/tuner (#28067) --- doc/source/ray-air/doc_code/tuner.py | 7 +++++-- doc/source/ray-air/trainer.rst | 5 ++++- 2 files changed, 9 insertions(+), 3 deletions(-) diff --git a/doc/source/ray-air/doc_code/tuner.py b/doc/source/ray-air/doc_code/tuner.py index 3fc456a4a..d5bd27232 100644 --- a/doc/source/ray-air/doc_code/tuner.py +++ b/doc/source/ray-air/doc_code/tuner.py @@ -176,7 +176,6 @@ config = TuneConfig( # __tune_optimization_end__ # __result_grid_inspection_start__ -from ray.air.config import RunConfig from ray.tune import Tuner, TuneConfig tuner = Tuner( @@ -201,7 +200,11 @@ best_checkpoint = best_result.checkpoint # And the best metrics best_metric = best_result.metrics -# Inspect all results +# Or a dataframe for further analysis +results_df = result_grid.get_dataframe() +print("Shortest training time:", results_df["time_total_s"].min()) + +# Iterate over results for result in result_grid: if result.error: print("The trial had an error:", result.error) diff --git a/doc/source/ray-air/trainer.rst b/doc/source/ray-air/trainer.rst index 1061fd086..aa8a8590b 100644 --- a/doc/source/ray-air/trainer.rst +++ b/doc/source/ray-air/trainer.rst @@ -212,8 +212,11 @@ You can interact with a `Result` object as follows: # returns the final metrics as reported result.metrics - # returns the contain an Exception if training failed. + # returns the Exception if training failed. result.error + # Returns a pandas dataframe of all reported results + result.metrics_dataframe + See :class:`the Result docstring ` for more details.