Skip to content

visualizing topics #3

@fja123

Description

@fja123

Dear GSukr,
I use your very good code to visualize time varying topics. I can see the changes in the top 10 words of each topic without any problems in figures. But this is not the case with the topics. Would you please kindly help me in this regard? The relevant code is as below:

import pandas

result = pandas.read_csv('../sample-data/sample1.csv', encoding='utf_8')
news_abstract = result['newsAbstract']
news_text_normal = result['textField_normal']
news_time = result['time_jalali']

import dtmvisual

time_seq = [100,150,150,100]
dtm_path = 'C:/Downloads/dtm-win64.exe'

from dtmvisual.gensim_corpus import docs_to_list, corpus_dtm
sentences = docs_to_list(news_abstract)
corpus = corpus_dtm(sentences)

from dtmvisual.DTMmodel import dtm_model
model = dtm_model(dtm_path, corpus, time_seq, num_topics=8,
id2word=corpus.dictionary, alpha=0.01)

number_of_timespans = 4
number_of_topics = 8

from dtmvisual import visualize_words
df = visualize_words.DF(number_of_timespans, number_of_topics, model)
d = visualize_words.partitioning(df)
visualize_words.visualize_words(df, d)

#--------Topics evolution------
from dtmvisual import VisualizeTopics
df = VisualizeTopics.topic_distribution(number_of_topics, model, time_seq)
VisualizeTopics.visualize_topics(df)
'''
#Moreover, you save and then download your DTM model using:
dtmvisual.save_model(model, output_path, output_name)
model = dtmvisual.load_saved_model(output_path, output_name)
#To print the words for a timeslice for a topic use:
'''
from dtmvisual import DTMmodel
DTMmodel.print_all_topics(model, topicid = 7, time = 4, num_words=10)

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions