Skip to content

Query metrics history of trials more easilyΒ #236

Open
@letmaik

Description

@letmaik

I need to retrieve the per-epoch training history of the metrics for each trial. I'm aware that this is not exposed in the public API yet, but since I need it I had a go anyway:

for trial in tuner.oracle.get_best_trials(num_trials=10):
  metrics_tracker = trial.metrics # type: MetricsTracker
  metric_histories = metrics_tracker.metrics # type: Dict[str, MetricHistory]
  mse = metric_histories['mse'] # type: MetricHistory
  mse_obs = mse.get_history() # type: List[MetricObservation]
  # assumption: executions_per_trial=1
  mse_values = [obs.value[0] for obs in mse_obs] # type: List[float]
  print(f'mse: {mse_values})

This works, but seems quite cumbersome. Are there plans to expose the histories in a more high-level way? Something along the lines of trial.get_history(aggregate='mean') which simply returns a dictionary that maps metric name to list of floats. If aggregate is not given or None then it could return a dictionary from metric name to list of list of floats, where the outer list is per execution.

Metadata

Metadata

Assignees

Labels

questionFurther information is requested

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions