吳小晴 萬國金 李程文 林夢思 曹書強(qiáng)
摘 ?要: 傳統(tǒng)的TF?IDF算法沒有很好地分配分詞的權(quán)重,對一些能代表郵件類別出現(xiàn)頻率較大的詞語計算的IDF值反而較小,IDF值小說明單詞的區(qū)分能力弱而不符合實際情況。為了提升垃圾郵件識別的準(zhǔn)確率,提出一種改進(jìn)TF?IDF算法和類中心向量的中文垃圾郵件識別方法。通過改進(jìn)傳統(tǒng)的TF?IDF計算方式,在傳統(tǒng)的TF?IDF算法里面加入卡方統(tǒng)計量CHI和位置影響因子能夠很好地改善一些重要詞匯的權(quán)重問題,并結(jié)合逆向最大匹配算法的郵件文本分詞和類中心向量算法的特征選擇進(jìn)行垃圾郵件分類。實驗結(jié)果表明,所提算法相較于傳統(tǒng)的TF?IDF算法對垃圾郵件識別的準(zhǔn)確率提升了約3.6%,具有一定的實際應(yīng)用價值。
關(guān)鍵詞: TF?IDF算法; 郵件識別; 卡方統(tǒng)計量; 權(quán)重分配; 郵件分類; 仿真分析
中圖分類號: TN911.23?34; TP181 ? ? ? ? ? ? ? 文獻(xiàn)標(biāo)識碼: A ? ? ? ? ? ? ? ? ? ? ?文章編號: 1004?373X(2020)12?0083?04
Abstract: A Chinese spam recognition method with improved TF?IDF algorithm and class centre vector is proposed to improve the accuracy of spam recognition. The traditional TF?IDF algorithm does not assign the weight of word segmentation well, and the calculated IDF value for some words that can represent the mail category and has higher frequency of occurrence is relatively small. The small IDF value indicates that the capacity of distinguishing the words is weak and does not accord with the actual demand. In this paper, the traditional TF?IDF calculation pattern is improved. The traditional TF?IDF algorithm adding the chi?square statistic CHI and position influence factor can improve the weight of some important words, and the spam classification can be performed by combining it with the feature selection of class center vector algorithm and mail text segmentation of the reverse maximum matching algorithm. The experimental results show that, in comparison with the traditional TF?IDF algorithm, this algorithm can increase the accuracy of spam identification by about 3.6%, which has a certain practical application value.
Keywords: TF?IDF algorithm; mail recognition; CHI; weight allocation; mail classification; simulation analysis
0 ?引 ?言
如今郵件成為日常溝通通信的主要方式之一,而垃圾郵件的存在給用戶帶來困擾。在卡巴斯基實驗室發(fā)布的2018年第二季度垃圾郵件和釣魚郵件的數(shù)據(jù)里,來自中國的垃圾郵件數(shù)目占郵件總量的14.36%,在統(tǒng)計的國家中國排名第一[1]。郵件分類識別的常用方法有基于IP地址和域名的黑白名單攔截方法、樸素貝葉斯算法[2]、決策樹算法[3]、支持向量機(jī)算法[4]、K近鄰算法分類[5]、類中心向量算法?,F(xiàn)存在的技術(shù)在垃圾郵件識別準(zhǔn)確率并不是很高,故本文算法在傳統(tǒng)的TF?IDF算法[6]上改進(jìn),采用更精確的分詞算法與郵件特征詞向量的轉(zhuǎn)化算法,在保證正確提取郵件內(nèi)容的前提下提高垃圾郵件識別的準(zhǔn)確率。
1 ?郵件分類的常用方法介紹
1) 黑白名單攔截方法[7]?,F(xiàn)有一些組織和機(jī)構(gòu)專門管理郵件黑名單,處理垃圾郵件地址的問題。若一個IP地址被列入黑名單,ISP服務(wù)商就會屏蔽該IP地址,用戶則不會收到該地址發(fā)送的郵件。但是如果對方設(shè)置動態(tài)IP或者在不知道對方郵箱的前提下就沒辦法攔截郵件。
傳統(tǒng)的TF?IDF并不能很好地處理特征詞的權(quán)重問題。傳統(tǒng)的TF?IDF算法思想認(rèn)為,如果垃圾郵件類別中包含詞條[t]的郵件數(shù)為[m],非垃圾郵件包含[t]的郵件數(shù)為[k],則所有包含[t]的郵件數(shù)[n=m+k],當(dāng)[m]大的時候,[n]就會大,TF?IDF公式得到的IDF的值會小,說明單詞[t]的區(qū)分能力不強(qiáng)。實際上,若某些詞條多次出現(xiàn)在一個類別的郵件中,則該詞條幾乎能夠代表這個類的郵件文本的特征,應(yīng)給予較高的權(quán)重,并選來作為該類郵件的特征詞。