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?
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
.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With