facebookresearch / hiplot

HiPlot makes understanding high dimensional data easy
https://facebookresearch.github.io/hiplot/
MIT License
2.74k stars 139 forks source link

HTML support for the table #219

Closed Emmanuelpean closed 2 years ago

Emmanuelpean commented 2 years ago

First time reporting a "bug" so please let me know if anything is wrong. HTML formatting is properly displayed in the graph labels but not in the table (see example below). Would it be possible to add html support to the table? Hiplot version: 1.31.0

import streamlit as st
import hiplot as hip

x1, x2, x3 = st.slider('x1'), st.slider('x2'), st.slider('x3')

data = [{'uid': 'a', 'dropout<sub>3</sub>': 0.1, 'lr': 0.001, 'loss': 10.0, 'optimizer': 'SGD', 'x': x1},
        {'uid': 'b', 'dropout<sub>3</sub>': 0.15, 'lr': 0.01, 'loss': 3.5, 'optimizer': 'Adam', 'x': x2},
        {'uid': 'c', 'dropout<sub>3</sub>': 0.3, 'lr': 0.1, 'loss': 4.5, 'optimizer': 'Adam', 'x': x3}]
xp = hip.Experiment.from_iterable(data)
xp.to_streamlit(key="hip").display()
danthe3rd commented 2 years ago

Hi @Emmanuelpean and thanks for the report :) Should be an easy fix for the next version - I'll try to work on that this month

danthe3rd commented 2 years ago

Actually I don't think it's a good idea to evaluate HTML by default. It shouldn't have been the case in the first place probably, as it might break a lot of stuff if we allow too many customization. However I totally understand your use-case. One way might be to use parameters_definition, like:

data = [{'uid': 'a', 'dropout_3': 0.1, 'lr': 0.001, 'loss': 10.0, 'optimizer': 'SGD', 'x': x1},
        {'uid': 'b', 'dropout_3': 0.15, 'lr': 0.01, 'loss': 3.5, 'optimizer': 'Adam', 'x': x2},
        {'uid': 'c', 'dropout_3': 0.3, 'lr': 0.1, 'loss': 4.5, 'optimizer': 'Adam', 'x': x3}]
xp = hip.Experiment.from_iterable(data)
xp.parameters_definition["dropout_3"].name_html = "dropout<sub>3</sub>"

what do you think?

Emmanuelpean commented 2 years ago

I think that would do the trick!