LDA4j
LDA4j copied to clipboard
A Java implemention of LDA(Latent Dirichlet Allocation)
LdaUtil Map rankMap = new TreeMap(Collections.reverseOrder()); 把double和string互换一下谢谢
首先感谢hankcs博主的分享,在使用LDA4j的过程中,我重写了Corpus类里的load和loadDocument方法,从数据库中读写数据测试成功。 但是测试的过程中遇到了一个问题,就是先用训练集训练出来phi,然后拿来一个新文档使用这个phi推断其概率分布发现报数组越界的错误,我初步调试发现一旦新文档中包含训练集中没有的生单词,你写的Inference便无法使用,这个问题希望博主能进行一下异常处理。
ldautil第41行应改为for (int i = 0; i < limit && iterator.hasNext() ; ++i),否则limit超过iterator的大小的时候会报错
有相关的api文档吗,请问如何获得新文档的主题分布? int[] document = Corpus.loadDocument("data/mini/军事_510.txt", corpus.getVocabulary()); double[] tp = LdaGibbsSampler.inference(phi, document); Map topic = LdaUtil.translate(tp, phi, corpus.getVocabulary(), 100); LdaUtil.explain(topic);