nuget server logo nuget api documents
↑

API Docs / Microsoft.VisualBasic.Data.NLP / LdaGibbsSampler

LdaGibbsSampler

Full name Microsoft.VisualBasic.Data.NLP.LDA.LdaGibbsSampler Assembly Microsoft.VisualBasic.Data.NLP Members 26

Gibbs sampler for estimating the best assignments of topics for words and documents in a corpus. The algorithm is introduced in Tom Griffiths' paper "Gibbs sampling in the generative model of Latent Dirichlet Allocation" (2002). Gibbs sampler采样算法的实现

@author heinrich

00 Remarks

https://github.com/hankcs/LDA4j

01 Syntax

Microsoft.VisualBasic.Data.NLP.LDA.LdaGibbsSampler

02 Methods

NameOverloadsSummary
.ctor 1 Initialise the Gibbs sampler with data.
initialState 1 Initialisation: Must start with an assignment of observations to topics ? Many alternatives are possible, I chose to perform random assignments with equal probabilities 随机初始化状态
gibbs 2 Main method: Select initial state ? Repeat a large number of times: 1.
sampling 1 for all z_i do chain data sampling
update_params 1 Add to the statistics the values of theta and phi for the current state.
configure 1 Configure the gibbs sampler 配置采样器

03 Properties

NameOverloadsSummary
K 1 number of topics 主题数目
Theta 1 Retrieve estimated document--topic associations.
Phi 1 Retrieve estimated topic--word associations.

04 Fields

NameOverloadsSummary
documents 1 document data (term lists) 文档
V 1 vocabulary size 词表大小
alpha 1 Dirichlet parameter (document--topic associations) 文档——主题参数
beta 1 Dirichlet parameter (topic--term associations) 主题——词语参数
z 1 topic assignments for each word.
nw 1 cwt[i][j] number of instances of word i (term?) assigned to topic j.
nd 1 na[i][j] number of words in document i assigned to topic j.
nwsum 1 nwsum[j] total number of words assigned to topic j.
ndsum 1 nasum[i] total number of words in document i.
thetasum 1 cumulative statistics of theta theta的累积量
phisum 1 cumulative statistics of phi phi的累积量
numstats 1 size of statistics 样本容量
THIN_INTERVAL 1 sampling lag (?) 多久更新一次统计量
BURN_IN 1 burn-in period 收敛前的迭代次数
ITERATIONS 1 max iterations 最大迭代次数
SAMPLE_LAG 1 sample lag (if -1 only one sample taken) 最后的模型个数(取收敛后的n个迭代的参数做平均可以使得模型质量更高)

05 Members

method .ctor #
#ctor(Int32()(), Int32, Action(Of Object))

Initialise the Gibbs sampler with data. 用数据初始化采样器

Parameters
NameTypeDescription
documentsInt32()()

文档

VInt32

vocabulary size 词表大小

method initialState #
initialState(Int32)

Initialisation: Must start with an assignment of observations to topics ? Many alternatives are possible, I chose to perform random assignments with equal probabilities 随机初始化状态

Parameters
NameTypeDescription
KInt32

number of topics K个主题

method gibbs overload 2 #
gibbs(Int32)

with default cutoff alpha=2.0 and beta=0.5

Parameters
NameTypeDescription
KInt32

-

method gibbs #
gibbs(Int32, Double, Double)

Main method: Select initial state ? Repeat a large number of times: 1. Select an element 2. Update conditional on other elements. If appropriate, output summary for each run. 采样

Parameters
NameTypeDescription
KInt32

number of topics 主题数

alphaDouble

symmetric prior parameter on document--topic associations 对称文档——主题先验概率?

betaDouble

symmetric prior parameter on topic--term associations 对称主题——词语先验概率?

method sampling #
sampling(Int32)

for all z_i do chain data sampling

Parameters
NameTypeDescription
ziInt32

-

method update_params #
update_params

Add to the statistics the values of theta and phi for the current state. 更新参数

method configure #
configure(Int32, Int32, Int32, Int32)

Configure the gibbs sampler 配置采样器

Parameters
NameTypeDescription
iterationsInt32

number of total iterations

burnInInt32

number of burn-in iterations

thinIntervalInt32

update statistics interval

sampleLagInt32

sample interval (-1 for just one sample at the end)

property K #
K

number of topics 主题数目

property Theta #
Theta

Retrieve estimated document--topic associations. If sample lag > 0 then the mean value of all sampled statistics for theta[][] is taken. 获取文档——主题矩阵

Returns

theta multinomial mixture of document topics (M x K)

property Phi #
Phi

Retrieve estimated topic--word associations. If sample lag > 0 then the mean value of all sampled statistics for phi[][] is taken. 获取主题——词语矩阵

Returns

phi multinomial mixture of topic words (K x V)

field documents #
documents

document data (term lists) 文档

field V #
V

vocabulary size 词表大小

field alpha #
alpha

Dirichlet parameter (document--topic associations) 文档——主题参数

field beta #
beta

Dirichlet parameter (topic--term associations) 主题——词语参数

field z #
z

topic assignments for each word. 每个词语的主题 z[i][j] := 文档i的第j个词语的主题编号

field nw #
nw

cwt[i][j] number of instances of word i (term?) assigned to topic j. 计数器,nw[i][j] := 词语i归入主题j的次数

field nd #
nd

na[i][j] number of words in document i assigned to topic j. 计数器,nd[i][j] := 文档[i]中归入主题j的词语的个数

field nwsum #
nwsum

nwsum[j] total number of words assigned to topic j. 计数器,nwsum[j] := 归入主题j词语的个数

field ndsum #
ndsum

nasum[i] total number of words in document i. 计数器,ndsum[i] := 文档i中全部词语的数量

field thetasum #
thetasum

cumulative statistics of theta theta的累积量

field phisum #
phisum

cumulative statistics of phi phi的累积量

field numstats #
numstats

size of statistics 样本容量

field THIN_INTERVAL #
THIN_INTERVAL

sampling lag (?) 多久更新一次统计量

field BURN_IN #
BURN_IN

burn-in period 收敛前的迭代次数

field ITERATIONS #
ITERATIONS

max iterations 最大迭代次数

field SAMPLE_LAG #
SAMPLE_LAG

sample lag (if -1 only one sample taken) 最后的模型个数(取收敛后的n个迭代的参数做平均可以使得模型质量更高)