Visualizing Ray Tune resultΒΆ

[2]:
import os
import numpy as np
import pandas as pd
import plotly
import plotly.graph_objs as go
from ray.tune.visual_utils import load_results_to_df, generate_plotly_dim_dict
plotly.offline.init_notebook_mode(connected=True)
plotly.io.renderers.default = "notebook" # This is required to render the plot in Sphinx
[3]:
# Load the data from a tuning result directory
RESULTS_DIR = "/path/to/tune/results/"
df = load_results_to_df(RESULTS_DIR)

# Format the results a bit
to_show = {
    'Learning rate': lambda x: x['lr'],
    'L2 ratio':      lambda x: x['l2'],
    'Decay rate':    lambda x: x['dr'],
    'MAE (eV/atom)': lambda x: x['MAE'],
    'Time (min)':    lambda x: x['time_total_s']/60}
for k, v in to_show.items():
    df[k] = v(df)
df = df[to_show.keys()]
dimensions = [generate_plotly_dim_dict(df, field) for field in df]

# Visualize the tunning result
data = [go.Parcoords(
    line = dict(color = df['MAE (eV/atom)'], showscale = True),
    tickfont = dict(size=12), labelfont = dict(size=12),
    rangefont = dict(size=12), dimensions=dimensions)]

plotly.offline.iplot(data)