0

I saved an LDAWallet model:

First I did the train :

 mallet_path = 'mallet-2.0.8/bin/mallet'
 ldamallet = gensim.models.wrappers.LdaMallet(mallet_path, corpus=corpus, id2word=id2word, 
 num_topics=14)

And then I saved the model using the save method:

ldamallet.save('lda_v0.model')

I forgot the set the prefix to a certain file when I trained the mode, as a consequence I lost all the temporary files created by gensim when training (doctopics etc...). And I think that because of that, when I load the model and want to predict topics :

model_lda = gensim.models.ldamodel.LdaModel.load('lda_v0.model')
###stuff
###stuff
###stuff
model_lda[input]

I get an error :

[Errno 2] No such file or directory: '/var/folders/_f/ttl3hvqn75g4rb5cdg02qg1c0000gn/T/2e13a7_doctopics.txt.infer'

I tried unsuccessfully to reproduce the same model with the data (and setting the prefix so that I don't lose the temporary files). I'm wondering if it is possible to use the method print_topics (I forgot to say that loading the model is working and I can get all the topics and their words) and for each topics , retrieve the weight of the words related to the topics and compute the probability but I don't know how the lda model predict the topic for each document, so I'm not sure if my idea can work.

Do you have any idea how to fix this issue ? I only want to predict for a document the probabibity of each topic.

Thank you

1 Answers1

0

Issue fixed. I convert the malletmodel to ldamodel; and by doing that I was able to make the predictions.

model_lda = gensim.models.ldamodel.LdaModel.load(path_of the model)
ldamodel = gensim.models.wrappers.ldamallet.malletmodel2ldamodel(model_lda)

thank you.