我正在嘗試使用Java中的Apache Spark ML創建LDA模型。輸入文檔採用字符串格式。我以數字格式獲得主題,但不是以文字格式。 發現了類似的問題,但令人遺憾的是解決方案是在R- LDA with topicmodels, how can I see which topics different documents belong to?但我正在尋找使用Spark中的ML lib的解決方案。
中每個主題的詞語分佈p(w | t)我需要獲得以Java編程的Mallet找到的每個主題的單詞分佈(不在CLI中,如how to get a probability distribution for a topic in mallet?中所述)。對於我的意思的例子:Introduction to Latent Dirichlet Allocation: Topic A: 30% broccoli,
from nltk.tokenize import RegexpTokenizer
from stop_words import get_stop_words
from gensim import corpora, models
import gensim
import os
from os import path
from time import sleep
import matp