翻译自: https://cwiki.apache.org/confluence/display/MAHOUT/Latent+Dirichlet+Allocation
简介:
Latent Dirichlet Allocation (Blei et al, 2003)是一个强大的学习方法将words聚到一些topics里面,以及把一些document表示成topics的一些集合。
主题模型就是document在topics上的概率分布,和words在topics上的分布的一个层次贝叶斯模型,举个例子,一个topic是包括“体育”,“篮球”,"全垒打"等词,一个document讲述一些在篮球比赛中使用违禁药,可能包含"体育",“篮球”,“违禁药”,这些词,是事先被人类定义的标签,算法只不过给这些词跟概率关联上。模型中参数估计的目的是把这些topic学习出来,一个document跟这些topic的概率是多少。
另一个理解主题模型的视角是把他看作类似于 Dirichlet Process Clustering 的混合模型,从一个正常的混合模型开始,我们有一个全局混合的几个分布,我们可以说每一个document都有他全局分布之上自己的一个分布,在dirichlet process clustering中,每一个document在全局混合分布上有他自己的隐变量决定他属于哪个模型,在LDA中每一个词又有在document上的一个分布。
我们按照一定概率混合一些模型来解释已观测到的数据,每一个被观测到的数据假设是来自于许多模型中的一个,但是我们并不知道来自于哪一个,所以我们用一个称之为隐含变量的名字来指他从哪里来。
Collapsed Variational Bayes
CVB算法在LDA mahout的实现中结合了variational bayes 和 gibbs sampling .
使用方法:
mahout中LDA的实现需要工作在 一个稀疏的词频的向量上,词频一定要是一个非负数的,在概率模型中,负数没有意义,确保用的是TF而不是IDF作为词频。
调用方法如下:
bin/mahout cvb \
-i <input path for document vectors> \
-dict <path to term-dictionary file(s) , glob expression supported> \
-o <output path for topic-term distributions>
-dt <output path for doc-topic distributions> \
-k <number of latent topics> \
-nt <number of unique features defined by input document vectors> \
-mt <path to store model state after each iteration> \
-maxIter <max number of iterations> \
-mipd <max number of iterations per doc for learning> \
-a <smoothing for doc topic distributions> \
-e <smoothing for term topic distributions> \
-seed <random seed> \
-tf <fraction of data to hold for testing> \
-block <number of iterations per perplexity check, ignored unless test_set_percentage>0> \
选择topic的数量的时候,建议多试几次。
在运行LDA之后,可以使用工具打印出来结果:
bin/mahout ldatopics \
-i <input vectors directory> \
-d <input dictionary file> \
-w <optional number of words to print> \
-o <optional output working directory. Default is to console> \
-h <print out help> \
-dt <optional dictionary type (text|sequencefile). Default is text>
示例:
在mahout/examples/bin/build-reuters.sh 有详细的示例脚本,脚本自动下载数据集,建立lucence索引,把lucence索引再变成 向量的形式,注释掉最后两行,让他运行你的LDA,打印出来结果。
把样例改成你所需要的形式,需要自己建立lucence索引,需要一个adapter,剩下的东西都差不多。
参数估计:
使用EM算法。
分享到:
相关推荐
mahout 入门中文材料,是IBM文章汇总,值得一看
Mahout是基于Hadoop之上的机器学习和数据挖掘的一个分布式框架项目。搞机器智能学习算法,这个是首选。本文给出一个完整的编译运行示例,让有兴趣的同行少走段弯路,多一份参考!
Apache Mahout 简介
mahout 数据挖掘 数据分析 开源 hadoop
mahout,朴素贝叶斯分类,中文分词,mahout,朴素贝叶斯分类,中文分词,
mahout_help,mahout的java api帮助文档,可以帮你更轻松掌握mahout
maven_mahout_template-mahout-0.8
该资源是mahout in action 中的源码,适用于自学,可在github下载:https://github.com/tdunning/MiA
mahout中的贝叶斯算法的拓展开发包,提供了相关接口可以供用户调用,直接即可跑出结果,相关运行方式参考blog《mahout贝叶斯算法开发思路(拓展篇)》
MAHOUT实战 MAHOUT IN ACTION
mahout-examples-0.11.1 mahout-examples-0.11.1-job mahout-h2o_2.10-0.11.1 mahout-h2o_2.10-0.11.1-dependency-reduced mahout-hdfs-0.11.1 mahout-integration-0.11.1 mahout-math-0.11.1 mahout-math-0.11.1 ...
mahoutAlgorithms源码分析 mahout代码解析
mahout中bayesian算法的数据流,可以根据excel中的公式来推断出该算法的数据流
mahout in action 第一章 第二章 第三章第四章 第六章第七章 第九章
mahout聚类算法的介绍,例如:Canopy,KMeans,Fuzzy-KMeans,Spectral Clustering等参数介绍和适用场景介绍
mahout-integration-0.7mahout-integration-0.7mahout-integration-0.7mahout-integration-0.7
If you are a Java developer and want to use Mahout and Machine Learning to solve Big Data analytics use-cases then this book is for you. Familiarity with shell-scripts is assumed but no prior ...
mahout-core-0.9.jar+mahout-core-0.8.jar+mahout-core-0.1.jar
mahout0.9不能运行在hadoop2中,会报interface错误,用此新编译后的包,可实现mahout+hadoop2的运行环境,其中包括编译后的包及源码。
Mahout 官方文档,简单介绍Mahout概念及其安装和简单使用