Skip to content

Instantly share code, notes, and snippets.

@csiebler
Created October 14, 2020 15:08
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save csiebler/fa4f22e179b675a72e8fe40dcb070ab1 to your computer and use it in GitHub Desktop.
Save csiebler/fa4f22e179b675a72e8fe40dcb070ab1 to your computer and use it in GitHub Desktop.
Get metrics and hyperparameters for each run in HyperDriveStepRun in Azure Machine Learning
# Get the HyperDriveStep of the pipeline by name (make sure only 1 exists)
hd_step_run = HyperDriveStepRun(step_run=pipeline_run.find_step_run('hd_step01')[0])
# Get RunID for best run (we're lazy)
best_run_id = hd_step_run.get_best_run_by_primary_metric().id
# Get all hyperparameters that where tried
hyperparameters = hd_step_run.get_hyperparameters()
# Get all metrics for the runs
metrics = hd_step_run.get_metrics()
# Iterate through all runs and print metrics + hyperparameters
for run_id, hp in hyperparameters.items():
print(run_id, "===========")
print("Hyperparameters:\n", hp)
print("Metrics:\n", metrics[run_id])
# Just for the best run
print("BEST RUN:", best_run_id)
print("Hyperparameters for best run:\n", hyperparameters[best_run_id])
print("Metrics of best run:\n", metrics[best_run_id])
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment