h2oai / h2oai/wave

Handle punctuation in column names for plotting

Open
#537 3 comments 0 reactions 0 assignees View on GitHub
devx feature ui
Dominant language
Python
Stars
4.3k
Forks
371
Avg merge
26d 1h
Merged PRs (30d)
1

Description

#### Is your feature request related to a problem? Please describe

H2O Driverless AI and MLOps return predictions of binary and multi-class in the form of `name.0, name.1, ..., name.n`. UI plots fail if the x or y has a decimal in the name, without an error message (the page is just white). The user needs to replace the decimal in the name for the plot to work as expected.

#### Describe the solution you'd like
Automatically handle decimals in the feature names

#### Describe alternatives you've considered
Require all developers to handle this themselves and just add more documentation

#### Additional context
Example that works
```
from h2o_wave import site, ui, data
import pandas as pd
import numpy as np

page = site['/demo']

n = 100
df = pd.DataFrame(dict(
length=np.random.rand(n),
width=np.random.rand(n),
data_type=np.random.choice(a=['Train', 'Test'], size=n, p=[0.8, 0.2])
))

# Plot two numeric columns by each other and color based on a third, categorical column
page['scatter'] = ui.plot_card(
box='1 1 4 5',
title='Scatter Plot from Dataframe',
data=data(
fields=df.columns.tolist(),
rows=df.values.tolist(),
pack=True,
),
plot=ui.plot(marks=[ui.mark(
type='point',
x='=length', x_title='Length',
y='=width', y_title='Width',
color='=data_type', shape='circle',
)])
)

page.save()
```

Add a point to fail:
```
from h2o_wave import site, ui, data
import pandas as pd
import numpy as np

page = site['/demo']

n = 100
df = pd.DataFrame(dict(
length=np.random.rand(n),
width=np.random.rand(n),
data_type=np.random.choice(a=['Train', 'Test'], size=n, p=[0.8, 0.2])
))

df.columns = ['length', 'width', 'data.type']

# Plot two numeric columns by each other and color based on a third, categorical column
page['scatter'] = ui.plot_card(
box='1 1 4 5',
title='Scatter Plot from Dataframe',
data=data(
fields=df.columns.tolist(),
rows=df.values.tolist(),
pack=True,
),
plot=ui.plot(marks=[ui.mark(
type='point',
x='=length', x_title='Length',
y='=width', y_title='Width',
color='=data.type', shape='circle',
)])
)

page.save()
```

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.