0

I have generated following data:

  topic termWeights termNames
0   0   0.02788352873965973 christma
1   0   0.02232702425056217 dragon
2   0   0.019817406886504067    autumn
3   0   0.01850595162915197 everyth
4   0   0.016370882157494063    hors
.....................
8   0   0.014648323538626204    mysteri
9   0   0.01418412337079642 red
10  1   0.03093819711779432 call
11  1   0.029868336735626826    book

I am trying to visualize a topic model.

from bokeh.layouts import row
from bokeh.plotting import figure, show, output_file
import holoviews as hv, numpy as np, pandas as pd
hv.extension('matplotlib', 'bokeh', width=100)

ds=hv.Dataset(overAllTopics, ['topic','termWeights'], 'termNames').aggregate(function=np.nansum)
by_state = ds.to(hv.Curve, 'termWeights','termNames') 
by_state 

Following syntax helps me to following graph. If I change "topic" on the right hand side the header on the graph changes but the values in x axis and/or y axis does not change. My question is how do I change the right hand side dropdown to see changes in the left hand graph. Or any other advise is appreciated.

lpt
  • 931
  • 16
  • 35

2 Answers2

1

based on Andrew's help. see solution below. thanks Andrew:

enter image description here

lpt
  • 931
  • 16
  • 35
0

First, I recommend you ensure that your termWeights is float data type (it looks like string objects right now).

Then, I recommend using hv.Bars instead of hv.Curve since you only have one data point per topic (after you do .aggregate()) which is why you don't see anything. [Nevermind about this, I grouped by the wrong column in my example]

```

import numpy as np
import pandas as pd
import holoviews as hv
hv.extension('bokeh')
df = pd.read_csv('test.txt', delimiter='\s+')
df.dtypes

ds = hv.Dataset(df, ['topic','termWeights'], 'termNames').aggregate(function=np.nansum)

ds.to(hv.Bars, 'topic', 'termWeights', groupby='termNames')

```

bar

Andrew
  • 507
  • 5
  • 16