吳小晴 萬國金 李程文 林夢思 曹書強



摘 ?要: 傳統的TF?IDF算法沒有很好地分配分詞的權重,對一些能代表郵件類別出現頻率較大的詞語計算的IDF值反而較小,IDF值小說明單詞的區分能力弱而不符合實際情況。為了提升垃圾郵件識別的準確率,提出一種改進TF?IDF算法和類中心向量的中文垃圾郵件識別方法。通過改進傳統的TF?IDF計算方式,在傳統的TF?IDF算法里面加入卡方統計量CHI和位置影響因子能夠很好地改善一些重要詞匯的權重問題,并結合逆向最大匹配算法的郵件文本分詞和類中心向量算法的特征選擇進行垃圾郵件分類。實驗結果表明,所提算法相較于傳統的TF?IDF算法對垃圾郵件識別的準確率提升了約3.6%,具有一定的實際應用價值。
關鍵詞: TF?IDF算法; 郵件識別; 卡方統計量; 權重分配; 郵件分類; 仿真分析
中圖分類號: TN911.23?34; TP181 ? ? ? ? ? ? ? 文獻標識碼: 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 ?引 ?言
如今郵件成為日常溝通通信的主要方式之一,而垃圾郵件的存在給用戶帶來困擾。在卡巴斯基實驗室發布的2018年第二季度垃圾郵件和釣魚郵件的數據里,來自中國的垃圾郵件數目占郵件總量的14.36%,在統計的國家中國排名第一[1]。郵件分類識別的常用方法有基于IP地址和域名的黑白名單攔截方法、樸素貝葉斯算法[2]、決策樹算法[3]、支持向量機算法[4]、K近鄰算法分類[5]、類中心向量算法。現存在的技術在垃圾郵件識別準確率并不是很高,故本文算法在傳統的TF?IDF算法[6]上改進,采用更精確的分詞算法與郵件特征詞向量的轉化算法,在保證正確提取郵件內容的前提下提高垃圾郵件識別的準確率。
1 ?郵件分類的常用方法介紹
1) 黑白名單攔截方法[7]。現有一些組織和機構專門管理郵件黑名單,處理垃圾郵件地址的問題。若一個IP地址被列入黑名單,ISP服務商就會屏蔽該IP地址,用戶則不會收到該地址發送的郵件。但是如果對方設置動態IP或者在不知道對方郵箱的前提下就沒辦法攔截郵件。
傳統的TF?IDF并不能很好地處理特征詞的權重問題。傳統的TF?IDF算法思想認為,如果垃圾郵件類別中包含詞條[t]的郵件數為[m],非垃圾郵件包含[t]的郵件數為[k],則所有包含[t]的郵件數[n=m+k],當[m]大的時候,[n]就會大,TF?IDF公式得到的IDF的值會小,說明單詞[t]的區分能力不強。實際上,若某些詞條多次出現在一個類別的郵件中,則該詞條幾乎能夠代表這個類的郵件文本的特征,應給予較高的權重,并選來作為該類郵件的特征詞。