Fighting bird分享 http://blog.sciencenet.cn/u/tonia

博文

GibbsLDA++ 使用记录

已有 11892 次阅读 2013-1-18 02:21 |个人分类:data mining|系统分类:科研笔记| topic

1. 下载
解压:

$ gunzip GibbsLDA++.tar.gz

$ tar -xf GibbsLDA++.tar


2. 编译

$ make clean

$ make all


注意:如果出现以下错误:

g++ -c -o utils.o utils.cpp
utils.cpp: 在静态成员函数‘static int utils::parse_args(int, char**, model*)’中:
utils.cpp:69:28: 错误: ‘atof’在此作用域中尚未声明
utils.cpp:72:27: 错误: ‘atof’在此作用域中尚未声明
utils.cpp:75:24: 错误: ‘atoi’在此作用域中尚未声明
utils.cpp:78:29: 错误: ‘atoi’在此作用域中尚未声明
utils.cpp:81:31: 错误: ‘atoi’在此作用域中尚未声明
utils.cpp:84:29: 错误: ‘atoi’在此作用域中尚未声明
utils.cpp: 在静态成员函数‘static int utils::read_and_parse(std::string, model*)’中:
utils.cpp:270:41: 错误: ‘atof’在此作用域中尚未声明
utils.cpp:273:40: 错误: ‘atof’在此作用域中尚未声明
utils.cpp:276:37: 错误: ‘atoi’在此作用域中尚未声明
utils.cpp:279:37: 错误: ‘atoi’在此作用域中尚未声明
utils.cpp:282:37: 错误: ‘atoi’在此作用域中尚未声明
utils.cpp:285:41: 错误: ‘atoi’在此作用域中尚未声明
make[1]: *** [utils.o] 错误 1
make[1]:正在离开目录 `/home/tonia/GibbsLDA++-0.2/src'
make: *** [all] 错误 2

解决方法:
1). 在src/utill.cpp 文件头加入:
#include<stdio.h> #include<stdlib.h>
2). 在src/utill.h 文件头加入:
#include<stdlib.h>
3). 在src/lda.cp 文件头加入:
#include<stdio.h>
4). 重新make

编译成功后在 src 子文件夹下生成可执行文件 lda。

3.  按照指定格式准备输入文件

4. 模型估计

root@ubuntu:~/GibbsLDA++-0.2/src# lda -est
Please specify the input data file for model estimation!
Command line usage:
lda -est -alpha <double> -beta <double> -ntopics <int> -niters <int> -savestep <int> -twords <int> -dfile <string>
lda -estc -dir <string> -model <string> -niters <int> -savestep <int> -twords <int>
lda -inf -dir <string> -model <string> -niters <int> -twords <int> -dfile <string>

tonia@ubuntu:~/GibbsLDA++-0.2/src$ ./lda -est -alpha 0.5 -beta 0.1 -ntopics 100 -niters 1000 -savestep 200 -twords 20 -dfile /home/tonia/data/LDA_input_ready.txt

5. 结果文件

.others 各种参数
.phi word-topic 分布, i.e., p(word|topic)。每行是一个topic,每列是一个word;
.theta topic-document 分布, i.e., p(topic|document)。每行是一个document,每列是一个topic。
.twords n个topic,以及每个topic下面包含的word,个数由参数 -ntwords决定。
.tassign 最终对文档的topic assignment。每行是一个document,格式为 <wordij>:<topic of wordij>。









https://blog.sciencenet.cn/blog-425672-654209.html

上一篇:About frequent graph mining
收藏 IP: 69.136.240.*| 热度|

0

该博文允许注册用户评论 请点击登录 评论 (0 个评论)

数据加载中...

Archiver|手机版|科学网 ( 京ICP备07017567号-12 )

GMT+8, 2024-4-19 06:48

Powered by ScienceNet.cn

Copyright © 2007- 中国科学报社

返回顶部