how to get word-topic probability using mallet

房东的猫 提交于 2019-12-01 05:15:06

问题


I've made a parallel topic model using mallet.

And I want to get top-words for each document.

To do that, I'm trying to get a word-topic probability matrix.

How would I achieve this?


回答1:


When you are building topics using MALLET, you have an option called --word-topic-counts-file. When you give this option and specify a file, MALLET writes ( topic, word, probability ) values per each line in the file. You can later read this file in C, Java or R (of course, any language) to create the matrix you want.




回答2:


Just to make one point regarding the answer of Praveen.

Using the --word-topic-counts-file, MALLET will create a file which first few rows look something like this:

0 elizabeth 19:1
1 needham 19:2 17:1
2 died 19:2
3 mother 17:1 19:1 14:1

where first line means that the word elizabeth has been present in the topic 19 once; second line means that the word needham is associated two times with the topic 19, and with the topic 17 once; and so on...
Although, this file doesn't give you explicit probabilities, you can use it to calculate them.



来源:https://stackoverflow.com/questions/19661094/how-to-get-word-topic-probability-using-mallet

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