Open harelhan opened 6 years ago
Are you saying that the standalone HTML doesn't do what you need it to do? Once you've created the HTML file, you don't need to run the model again to view the visualisation
In case someone is still interested into reading already prepared data back into pyLDAvis:
import json
import pandas as pd
from pyLDAvis import PreparedData
filename = 'file.json'
def prepared_data_from_dict(vis_data):
topic_coordinates = pd.DataFrame.from_dict(vis_data['mdsDat'])
topic_info = pd.DataFrame.from_dict(vis_data['tinfo'])
token_table = pd.DataFrame.from_dict(vis_data['token.table'])
R = vis_data['R']
lambda_step = vis_data['lambda.step']
plot_opts = vis_data['plot.opts']
client_topic_order = vis_data['topic.order']
return PreparedData(topic_coordinates, topic_info,
token_table, R, lambda_step, plot_opts, client_topic_order)
with open(filename + '.json', 'r') as json_file:
dict_data = json.load(json_file)
viz_data = prepared_data_from_dict(dict_data)
pyLDAvis.display(viz_data)
This was really helpful to me, thanks!
Hi
I am new to python and pyLDAvis. I was able to export the vizualisation as html and the data as json. However, I wanted to know if there is a way to load the data from disk and show the visualization. I don't want to run the model every time in order to prepare the data as it is inefficient and resource intensive.
Any help would be really appreciated.
Thanks Hitesh