朴素贝叶斯与Softmax回归在文本分类上的对比研究

2021-11-28 02:24:54李咏豪李伦波
电脑知识与技术 2021年28期

李咏豪 李伦波

摘要:文本分类问题是自然语言处理中的重要任务。本文将机器学习中的朴素贝叶斯模型以及Softmax回归应用于自动文本分类中,在清华新闻分类语料数据集上实现了基于多项分布与类条件分布假设实现了朴素贝叶斯模型,并使用BOOL、TF、IDF、TF-IDF四种特征权重训练了Softmax回归模型。最后,将两种模型在训练集与测试集上的性能进行对比。

关键词:朴素贝叶斯;Softmax回归;自然语言处理;文本分类

中图分类号:G642      文献标识码:A

文章编号:1009-3044(2021)28-0131-02

开放科学(资源服务)标识码(OSID):

A Comparative Study of Naive Bayes and Softmax Regression in Text Classification

LI Yong-hao*, LI Lun-bo

(College of Computer Science and Engineering, Nanjing University of Science & Technology, Nanjing 210094, China)

Abstract: Text classification is an important task in natural language processing. In this paper, the Naive Bayes model and Softmax regression in machine learning are applied to automatic text classification. The naive Bayes model is implemented on the Tsinghua news classified corpus data set based on the assumption of multinomial distribution and class conditional distribution. And the Softmax regression model is trained with four feature weights including BOOL, TF, IDF, and TF-IDF. Finally, we compare the performance of the two models on the training set and the test set.

Key words: naive bayes; softmax regression; natural language processing; text classification

1 引言

自然語言处理中的文本分类指的是给定文档,将文档归为n个类别中的1个。文本分类在现实生活中的用途十分广泛,比如,将社交媒体中短文按照其讨论内容分为不同的类别;在情感分析问题中,提取文档中人物表露的态度;在邮箱管理中,自动区别垃圾邮件与非垃圾邮件。

文本分类任务通常由传统的机器学习模型完成,如支持向量机[1]、朴素贝叶斯[2],也可由深度学习方法[3]实现。无论哪种统计学习模型,数据集对于模型性能都有着巨大的影响,本文中的模型使用了清华新闻分类语料数据集[4],它是根据新浪RSS订阅频道2005年至2011年间的历史数据筛选过滤生成的,包括74万篇新闻文档,10余个类别标签,数据集中句子已经过准确的分词,比如: 他 和 与 他 同辈 的 一 批 科学家 是 我国 计算机 技术 逼近 国际 先进 水平 的 希望 。同时,该数据集中包括一系列停用词,“我”“自己”等停用词十分常用,反而会影响新闻分类的精确度。……

登录APP查看全文