[air/docs] Add example to fetch results dataframe for trainer/tuner (#28067)

This commit is contained in:
Kai Fricke 2022-08-27 02:01:57 -07:00 committed by GitHub
parent e6b0d5f95d
commit bbd13ddc33
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 9 additions and 3 deletions

View file

@ -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)

View file

@ -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 <ray.air.result.Result>` for more details.