Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

MALLET topic-inference

Tags:

java

bash

mallet

I am trying to infer the topics of a document based on my trained topic model by MALLET. I am using the following command in the mallet dir

./mallet infer-topics --inferencer topic-model --input indata.mallet --output-doc-topics infered_docs

but it gets stuck in cast exception:

java.lang.ClassCastException: cc.mallet.topics.ParallelTopicModel cannot be cast to cc.mallet.topics.TopicInferencer how can I solve this?

like image 406
Sarah ESL Avatar asked Dec 19 '16 08:12

Sarah ESL


1 Answers

There's a difference between a model and an inferencer. The --output-model FILENAME option in the train-topics command produces a file (a model) that contains the training data along with all the inferred parameters. The --inferencer-filename FILENAME produces a much smaller file (an inferencer) that only contains the parameters needed to infer topics for new documents.

The infer-topics command needs a topic inferencer, not a complete model. You can create an inferencer from the existing model file by running train-topics with the --input-model FILENAME and --inferencer-filename FILENAME options, with --num-iterations 0.

like image 195
David Mimno Avatar answered Sep 17 '22 17:09

David Mimno