Closed teresaibarra closed 5 years ago
Hi!
The issue seems to be in your get_document_topics_json():
for it_index, it_val in sorted_list:
topic_list.append(self.corpus.idx2token[it_index])
get_document_topics() returns topic IDs for a given document, so sorted_list is a list of topic IDs. You convert these using corpus.idx2token, which is a mapping from token ID to token.
If you really want to obtain words for each document/song, you would need to combine document-topic assignments and topic-word assignments somehow. Although, I don't think that makes much sense, as it's easier and probably more meaningful to directly show the actual words of that document.
Considering that your data set is rather small, I would suggest starting out with fewer topics and/or getting more data.
-Samuel
I may have misunderstood how your code works. To clarify, this project returns topic clusters for each document (ie the topic cluster would be 1
, and words in that topic cluster would be 1: walk, may, away, beauti, look, voic, hi, memori, turn, everyon
)?
That's correct. The structure is the same as in Latent Dirichlet Allocation, i.e., a topic is a (fuzzy) cluster of documents, whose meaning is described by keywords.
Hi there,
I was able to run this on my own dataset, but I'm getting some strange and unexpected behavior. I'm able to generate topics and weights for each document, but the topics returned are only words from the first document. I've attached some examples if this isn't clear. A fork to my code can be found here.
Changing the number of topics seems to help get indices of unique topics but I'm unsure how that impacts the generated model.
Running
print_topic_words
gives me the below output, which shows there are some great topics within my dataset:Here are the topics generated for each song:
Note that all the generated topics are words from the first song "She's My Kind of Girl", but are not relevant for any other documents in my dataset. Please let me know if what I'm saying is unclear.