Please enable JavaScript.
Coggle requires JavaScript to display documents.
Text Classification and Naïve Bayes - Coggle Diagram
Text Classification and Naïve Bayes
text classification problem
定義
input:
document space X
output:
Class C
training set D
D = {<d, c>}, <d, c>屬於X * C
classifier(分類器):
r:X -> C
r從training data中訓練來,L(D) = r
r產生後,要有一組testing data評估
testing data與training data要分開取
one of/any of classification
one of:只能屬於一種
any of :屬於任一一種
Naive Bayes classification method
以機率為基礎的分類器
MAP(maximum a posteriori)
P(c)事前機率(prior probability):預先、修正前
P(c|d)事後機率(posterior probability)
2個model
multinomial model
testing時,P(d|c) = P( <tf1,d, …, tfM,d> | c)
依chain rule太複雜
做assumption1,conditional independence,互相獨立:
但不夠,參數過多,文章字數無限制
->做assumption2,positional independence
同個term用同一個probablitity,不依位置改變
結果:
m維向量
定義:
一實驗中,Y1發生y1次的發生機率
Bernoulli model
P(d|c) = P( <e1, …, eM> | c)
binary:1,0
有做independence assumption
positional assumption:做BIM時就一起處理了
training
用文章數算
分子:The number of training
documents in c containing term i
分母: The number of training
documents in class c
文章中沒使用的term也有影響
不考慮token出現次數
效能不錯,且有效率,業界常用
why multinomial?
P(d|c)
文章字數
字典字數
training part
分子:Tctk某個term的出現次數
分母:屬於該class中的總字數
problem
problem1:floating point underflow
解法:取log
problem2:zero probability
訓練時可能有自並沒出現在某個class中,但Test可能有 -> 0
解法:add-1 smoothing
Feature selection
why
data可能太大,不是每個term都有鑑別力
用途:提升效率
方法
time square
test the independence of two random variables
two random variables are
document有沒有用到這個term
document屬於哪個class
越趨近0:獨立的假設合理
<->
越大:獨立的假設不合理
值越大可能是正指標OR反指標
likelihood ratio(較佳?)
比較差異性,較有解釋力
It is a number of likelihood ratio of two hypotheses
hypothesis
Hypothesis 1. P(t|c) = P(t|not c) = pt (獨立)
Hypothesis 2. P(t|c) = p1 ≠ p2 = P(t|not c) (非獨立)
做binomial experiments
-2logλ = -2log(L(H1) / L(H2))
值越大可能是正指標OR反指標
pointwise mutual information(不建議用)
找出collocation(term特殊用法、關係)
找出term與class關係
如果t,c互相獨立
-> 0
常找到罕用字(不好)
大多找出independence的Term
改善:加入term frequency
countt,c X I(t,c)
Expected mutual information
除11外。10、01、00的情形也計入
不會有負值
但有反指標
frequency-based feature selection
依使用的model而定
頻率高低不一定有代表性
懶人法
使用限制:選的字數量要多
Feature selection for multiple classifier
算出全部class的feature,再平均
用
time square 做n*2的矩陣
Text classification evaluation
資料集
Reuters-21578 collection
Reuters-RCV1
算分數的衡量方法
Marco-averaging
考量大小資料(規模)分類情形
micro-averaging
把據鎮資料混再一起,再算
大資料分類會吃掉小分類資料