Hi,
Maybe a stupid question but does the holoviews dynamic mapping of streaming dataframes from streamz works with non-time series type data ?
Thanks,
Hi,
Maybe a stupid question but does the holoviews dynamic mapping of streaming dataframes from streamz works with non-time series type data ?
Thanks,
Absolutely, it should work with any kind of data.
I’m just trying to update a hv.table with some string dataframes.
My objective is to end-up with bar plots/other dashboards like representations but my string get recognized as Nan. Which I agree they are though.
Make sure your plot function can handle the data in your dataframe (including NAs).
This is the kind of code I typically use; you might find it of interest:
def make_monitor(sz=10):
data_def = { 'iteration':int, 'training_loss': np.float32, 'testing_loss': np.float32, 'x': object, 'x_': object }
sample_data = pd.DataFrame( {i:[] for i in data_def.keys()}, columns=data_def.keys())\
.astype(dtype=data_def)
buffer = hv.streams.Buffer(sample_data, length=sz, index=False)
def monitor(dat):
return buffer.send( pd.DataFrame( [dat], columns=data_def.keys() )\
.astype(dtype=data_def) )
def plot(data):
try:
h_loss = (hv.Curve( data, 'iteration', 'training_loss', label='training')*\
hv.Curve( data, 'iteration', 'testing_loss', label='testing'))
h_x = hv.Image(data['x' ].iloc[-1], kdims=['data','subframe'] )
h_x_ = hv.Image(data['x_'].iloc[-1], kdims=['data','subframe'] )
except:
h_loss = (hv.Curve([], 'iteration', 'training_loss', label='training')*\
hv.Curve([], 'iteration', 'testing_loss', label='testing'))\
.opts('Curve', width=500,title='Loss',show_grid=True)
h_x = hv.Image([], kdims=['data','subframe'] ).opts(width=500, xaxis=None,yaxis=None)
h_x_ = hv.Image([], kdims=['data','subframe'] )
return (h_loss.opts('Curve', width=500,title='Loss',show_grid=True) +\
h_x .opts(width=500, xaxis=None,yaxis=None) +\
h_x_.opts(width=500, xaxis=None,yaxis=None)
).cols(1)
return buffer, monitor, plot
monitor_datastream, monitor, monitor_plot = make_monitor(sz=10) #hv.streams.Buffer(monitor_data, length=100, index=False)
monitor_dmap = hv.DynamicMap( monitor_plot, streams=[monitor_datastream])
display(monitor_dmap)
use streamz to invoke
monitor((1,1.1,1.2,data,data))
Works perfectly, thanks
Okay, I spoke too fast and, again, sorry for the naive question.
It works perfectly for a simple case of hv.Tables which was my priority.
Staying on basic categorical data plots I tried hv.Bars, which works only half-way.
I use the same code, but then, while holoviews displays my categorical variables in the legend and updates the axis as the dataframe stream implies. It does not show any bars.
Is there again something I have missed ?
Adding a piece of the code here :
h_boxplot = hv.BoxWhisker(data,kdims=‘key’, vdims=‘value’)
this works perfectly
h_bars = hv.Bars(data,key_dimensions,value_dimensions)
h_bars.opts(opts.Bars(color=hv.Cycle('Category20'),\
show_legend=True,tools=['hover'],stacked=True,show_grid=True))
This seems to work, definitely reads the data, but doesn’t plot any bars for some reason