Search code examples
tensorboardtensorflow-servinghyperparameters

How to plot parallel coordinae plot ftrom Hyperparameter Tuning with the HParams Dashboard?


I am trying to replicate the parallel coordinate plot form Hyperparameter Tuning tutorial in this Tensorflow tutorial and I have writen my own csv file where I store my results. My output reading the csv file is like this:

    conv_layers  filters  dropout  accuracy
0             4       16      0.5  0.447917
1             4       16      0.6  0.458333
2             4       32      0.5  0.635417
3             4       32      0.6  0.447917
4             4       64      0.5  0.604167
5             4       64      0.6  0.645833
6             8       16      0.5  0.437500
7             8       16      0.6  0.437500
8             8       32      0.5  0.437500
9             8       32      0.6  0.562500
10            8       64      0.5  0.562500
11            8       64      0.6  0.437500

How can I create the same plot like in the tutorial in python?


Solution

  • so I found the answer using plotly

    import os
    import sys
    import pandas as pd
    from plotly.offline import init_notebook_mode, iplot
    import plotly.graph_objects as go
    
    init_notebook_mode(connected=True)
    
    df = pd.read_csv('path/to/csv')
    
    fig = go.Figure(data=
        go.Parcoords(
            line = dict(color = df['accuracy'],
                      colorbar = [],
                       colorscale = [[0, '#6C9E12'], ## 
                                    [0.25,'#0D5F67'], ##
                                    [0.5,'#AA1B13'], ## 
                                    [0.75, '#69178C'], ## 
                                    [1, '#DE9733']]),
            dimensions = list([
                dict(range = [0,12],
                    label = 'Conv_layers', values = df['conv_layers']),
                dict(range = [8,64],
                    label = 'filter_number', values = df['filters']),
                dict(range = [0.2,0.8],
                    label = 'dropout_rate', values = df['dropout']),
                dict(range = [0.2,0.8],
                    label = 'dense_num', values = df['dense']),
                 dict(range = [0.1,1.0],
                    label = 'accuracy', values = df['accuracy'])
            ])
        )
    )
    
    
    fig.update_layout(
        plot_bgcolor = '#E5E5E5',
        paper_bgcolor = '#E5E5E5',    
        title="Parallel Coordinates Plot"
    )
    
    # print the plot
    fig.show()