Latent Dirichlet Allocation(LDA)主题模型算法实现及源码解析
来源:互联网 发布:淘宝异常订单处理中心 编辑:程序博客网 时间:2024/05/17 22:39
变量说明:
整个程序步骤如下图
代码解析
1 读入文档:
首先要读入语料库中的文档。每个文件行,开头是一个数字,代表有多少单词,接着是id:count的形式,id代表单词的id号,count代表文档中这个单词出现的次数。读入的文档集合保存在document结构体中。
typedef struct {
main()函数中打开文件:
if ((data = feature_matrix(argv[optind], &nlex, &dlenmax)) == NULL) {
2 调用lda_learn开始学习
void
{ ……
for (i = 0; i < nclass; i++)
for (i = 0, z = 0; i < nclass; i++)
for (i = 0; i < nclass; i++)
qsort(alpha, nclass, sizeof(double), // 为alpha排序
//初始化beta
for (i = 0; i < nlex; i++)
2)初始化充分统计量,variational inference中需要用到的变量等
gammas和betas相当于gamma和beta的和,gamma和beta代表的是某一个文档,而gammas和betas代表的是所有文档
if ((gammas = dmatrix(n, nclass)) == NULL) {
}
if ((betas = dmatrix(nlex, nclass)) == NULL) {
}
//initialize buffers
if ((q = dmatrix(dlenmax, nclass)) == NULL) {
}
if ((gamma = (double *)calloc(nclass, sizeof(double))) == NULL)
{
}
if ((ap = (double *)calloc(nclass, sizeof(double))) == NULL) {
}
if ((nt = (double *)calloc(nclass, sizeof(double))) == NULL) {
}
if ((pnt = (double*)calloc(nclass, sizeof(double))) == NULL) {
}
3)开始EM迭代,如果迭代次数超过设定值则跳出
for (t = 0; t < emmax; t++)
{
4)计算似然函数,判断是否收敛
原文地址:http://blog.sina.com.cn/s/blog_8eee7fb60101d06p.html
- Latent Dirichlet Allocation(LDA)主题模型算法实现及源码解析
- Latent Dirichlet Allocation(LDA)主题模型算法实现及源码解析
- LDA(Latent Dirichlet Allocation)主题模型算法
- LDA(Latent Dirichlet Allocation)主题模型算法
- LDA(Latent Dirichlet Allocation)主题模型算法
- LDA(Latent Dirichlet Allocation)主题模型算法
- LDA(Latent Dirichlet Allocation)主题模型算法
- 一个LDA(Latent Dirichlet Allocation)主题模型的Java实现
- Latent Dirichlet Allocation(LDA)主题模型理论
- Latent Dirichlet Allocation(LDA)主题模型理论
- LDA(Latent Dirichlet Allocation)主题模型
- Latent Dirichlet Allocation 主题模型算法
- LDA 主题模型(latent dirichlet allocation) 介绍
- Introduction to Latent Dirichlet Allocation (LDA主题模型入门)
- latent Dirichlet allocation (LDA)
- Latent Dirichlet Allocation(LDA)
- Latent Dirichlet Allocation (LDA)
- Latent Dirichlet Allocation (LDA)
- 也说说LDA(Latent Dirichlet Allocation)——理论篇
- 学习Topic Model(主题模型)--Latent Dirichlet Allocation(LDA) 的一些摘要
- Apache设置多端口映射
- LDA(latent dirichlet allocation)的应用
- Latent Dirichlet Allocation(LDA)主题模型理论
- Latent Dirichlet Allocation(LDA)主题模型算法实现及源码解析
- 黑马程序员——集合类(2)
- LDA(Latent Dirichlet Allocation)主题模型算法
- makefile详细用法
- Latent dirichlet allocation note
- 输出二叉树中随机两个结点的最小公共父结点
- C语言中printf直接打出2进制数是%什么?16进制是什么?
- 黑马程序员——IO流
- iOS之代码混淆