Reputation: 341
I am able to create the lda model and save it. Now I am trying load the model, and pass a new document
lda = LdaModel.load('..\\models\\lda_v0.1.model')
doc_lda = lda[new_doc_term_matrix]
print(doc_lda )
On printing the doc_lda I am getting the object. <gensim.interfaces.TransformedCorpus object at 0x000000F82E4BB630>
However I want to get the topic words associated with it. What is the method I have to use. I was referring to this.
Upvotes: 2
Views: 1038
Reputation: 691
Not sure if this is still relevant, but have you tried get_document_topics()
? Though I assume that would only work if you've updated your LDA model using update()
.
I don't think there is anything wrong with your code - the "Usage example" from the documentation link you posted uses doc2bow
which returns a sparse vector - I don't know what new_doc_term_matrix
consists of, but I'll assume it worked fine.
You might want to look at this stackoverflow question: you want to print
an "object" - that isn't printable, the data you want is somewhere in the object, and that in itself is printable.
Alternatively, you can also use your IDE's capabilities - the Variable explorer in Spyder, for example - to click yourself into the objects and get the info you need.
For more info on similarity analysis with gensim, see this tutorial.
Upvotes: 1