0

I'm using IBM Watson Studio as a cloud service, jupyter notebook, Python 3.9, and trying to render a network diagram using the PyVis library. The code works / no errors, but the graph / html will not render, and returns 'Error: 404 Not Found' and 'openresty'

I am using the 'notebook=True' option which should render it in the notebook. Any help on how to render the graph / image / html within Watson Studio Notebook environment (server based)?

The following code executes (taken from the PyVis tutorial), but does not render the graph / image in a Watson Studio Notebook.

from pyvis.network import Network
import pandas as pd

got_net = Network(height='750px', width='100%', bgcolor='#222222', font_color='white', notebook=True)

# set the physics layout of the network
got_net.barnes_hut()
got_data = pd.read_csv('https://www.macalester.edu/~abeverid/data/stormofswords.csv')

sources = got_data['Source']
targets = got_data['Target']
weights = got_data['Weight']

edge_data = zip(sources, targets, weights)

for e in edge_data:
    src = e[0]
    dst = e[1]
    w = e[2]

    got_net.add_node(src, src, title=src)
    got_net.add_node(dst, dst, title=dst)
    got_net.add_edge(src, dst, value=w)

neighbor_map = got_net.get_adj_list()

# add neighbor data to node hover data
for node in got_net.nodes:
    node['title'] += ' Neighbors:<br>' + '<br>'.join(neighbor_map[node['id']])
    node['value'] = len(neighbor_map[node['id']])

got_net.show('gameofthrones.html')

1 Answers1

0
test - groupby('preds').sum()

to_vis = {}
for index in test.index:
    temp = test.loc[[index]].T.sort_values(by=index, ascending=False)[:30].to_dict()
    to_vis.update(temp)

g = Network(height='1000px', width='100%', notebook=True)

for cat, key_words in to_vis.items():
    g.add_node(cat, size = 9, color = 'red')
    for word in key_words:
        g.add_node(word, size = 3)
        g.add_edge(cat, word)
    
  • Did you get this to render the HTML when using Watson Studio on Cloud? (code doesn't work as is, but the code isn't the issue - its the rendering of the HTML). – Brian Naylor Apr 11 '22 at 13:34