rayray-tune

Best Config after Hyperparameter Search with Ray Tune


I just run my first Ray Tune. I got nice terminal output an all that but now I'm wondering: Which configuration gave me the best score?

I see that there are a ton of results files but is there an easy way to get the best config?


Solution

  • You can use the ExperimentAnalysis object returned by tune.run() to get the best config, like this:

    analysis = tune.run(trainable, search_alg=algo, stop={"training_iteration": 20})
    
    best_trial = analysis.best_trial  # Get best trial
    best_config = analysis.best_config  # Get best trial's hyperparameters
    best_logdir = analysis.best_logdir  # Get best trial's logdir
    best_checkpoint = analysis.best_checkpoint  # Get best trial's best checkpoint
    best_result = analysis.best_result  # Get best trial's last results
    best_result_df = analysis.best_result_df  # Get best result as pandas dataframe
    

    See the documentation: https://docs.ray.io/en/latest/tune/key-concepts.html#analysis