问题描述
这是MultiNomial NaiveBayes Pseudocode。
TRAINMULTINOMIALNB(C,D)
1 V←EXTRACTVABABARYARY(D)
2 N←COUNTDOCS(D)
每个c∈C
4做Nc←COUNTDOCSINCLASS(D,c)
5 previous [c]←Nc / N
6 textc←CONCATENATETEXTOFALLDOCSINCLASS(D,c)
每t'tV
8做Tct←COUNTTOKENSOFTERM(textc,t)
每个t∈V
10做condprob [t] [c]←Tct + 1
$ b $båt'(Tct'+ 1)
11返回V,优先,condprob
This is MultiNomial NaiveBayes Pseudocode .
TRAINMULTINOMIALNB(C,D)
1 V ← EXTRACTVOCABULARY(D)
2 N ← COUNTDOCS(D)
3 for each c ∈ C
4 do Nc ← COUNTDOCSINCLASS(D, c)
5 prior[c] ← Nc/N
6 textc ← CONCATENATETEXTOFALLDOCSINCLASS(D, c)
7 for each t ∈ V
8 do Tct ← COUNTTOKENSOFTERM(textc, t)
9 for each t ∈ V
10 do condprob[t][c] ← Tct+1
åt′ (Tct′+1)
11 return V, prior, condprob
APPLYMULTINOMIALNB(C,V, prior, condprob, d)
1 W ← EXTRACTTOKENSFROMDOC(V, d)
2 for each c ∈ C
3 do score[c] ← log prior[c]
4 for each t ∈ W
5 do score[c] += log condprob[t][c]
6 return argmaxc∈C score[c]
我有一个问题要把它改成C#代码。
有人可以帮我解决这个问题吗?
i've a problem to change it into C# code.
can someone help me to solve this?
推荐答案
这篇关于C#中的NaiveBayes Algorithim的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!