How to get topic vector of new documents and compare with pre-defined topic model in Mallet?

泄露秘密 提交于 2019-12-01 21:48:20

First, take a look at these:

Now, these examples show the basic functionality, but they don't show how to save and load the model if you need to separate training from testing. Basically what you need is to save both the model and the instances after training (since you need to train and test with the same pipeline), and load them before testing.

Save model and pipeline after training:

model.write(new File("model.dat"));
instances.save(new File("pipeline.dat"));

Load model and pipeline before testing:

ParallelTopicModel model = ParallelTopicModel.read(new File("model.dat"));
InstanceList instances = InstanceList.load(new File("pipeline.dat"));

Hope this helps.

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!