Skip to main content
QUICK REVIEW

[论文解读] Detecting Hate Speech and Offensive Language on Twitter using Machine Learning: An N-gram and TFIDF based Approach

Aditya Gaydhani, Vikrant Doma|arXiv (Cornell University)|Sep 23, 2018
Hate Speech and Cyberbullying Detection参考文献 6被引用 95
一句话总结

该论文使用基于 n-gram TFIDF 特征的三分类器(Twitter 数据:仇恨言论、冒犯性语言、干净)并比较 Logistic Regression、Naive Bayes、SVM,其中 Logistic Regression 在测试准确率上达到最佳,为95.6%。

ABSTRACT

Toxic online content has become a major issue in today's world due to an exponential increase in the use of internet by people of different cultures and educational background. Differentiating hate speech and offensive language is a key challenge in automatic detection of toxic text content. In this paper, we propose an approach to automatically classify tweets on Twitter into three classes: hateful, offensive and clean. Using Twitter dataset, we perform experiments considering n-grams as features and passing their term frequency-inverse document frequency (TFIDF) values to multiple machine learning models. We perform comparative analysis of the models considering several values of n in n-grams and TFIDF normalization methods. After tuning the model giving the best results, we achieve 95.6% accuracy upon evaluating it on test data. We also create a module which serves as an intermediate between user and Twitter.

研究动机与目标

  • 推动对 Twitter 上有毒语言的自动检测,以区分仇恨言论与冒犯性语言及无害内容。
  • 开发一个将来自多个公开数据集和 Twitter API 的数据结合起来训练和评估分类器的流水线。
  • 系统地比较不同 n-gram 范围和 TFIDF 归一化在多种分类器中的效果,以确定有效的特征-分类器组合。
  • 调整超参数以最大化交叉验证性能,并报告最终测试结果。

提出的方法

  • 从推文中提取 unigram 至 trigram 的 n-gram 特征,使用 TFIDF 加权。
  • 评估 L1 和 L2 TFIDF 归一化以及三种分类器:Naive Bayes、Logistic Regression 和 SVM。
  • 对特征参数进行网格搜索并进行 10 折交叉验证以比较模型。
  • 对 Naive Bayes 的平滑参数 alpha 和 Logistic Regression 的正则化参数 C 及求解器进行调优。
  • 基于交叉验证选择最佳模型,然后报告测试性能并分析错误。

实验结果

研究问题

  • RQ1是否能够使用 TFIDF 加权的 n-gram 特征让三分类器可靠地区分仇恨推文、冒犯性推文与干净推文?
  • RQ2哪种分类器(NB、LR、SVM)以及哪种特征设置能取得最高的交叉验证和测试性能?
  • RQ3TFIDF 归一化和 n-gram 范围如何影响仇恨言论和冒犯性语言的检测性能?
  • RQ4常见的错误分类模式是什么、提升冒犯类召回率和减少仇恨误分类的潜在改进?

主要发现

模型N-gram 范围 + TFIDF 归一化交叉验证准确率测试/最终准确率
Naive Bayes1-3 + L20.9340.934
Logistic Regression1-3 + L20.9510.956
Support Vector Machines1-3 + L20.901-
  • 使用 1-3 个 n-gram 与 L2 TFIDF 归一化的 Logistic Regression 在三种模型中实现最高的交叉验证性能,且在调优后超过其他模型。
  • Naive Bayes,alpha = 0.1 且 L2 TFIDF 达到 93.4% 的交叉验证准确率,超过初始结果并与 LR 相近竞争。
  • 最终评估的 Logistic Regression 模型在测试数据上达到 95.6% 的准确率,n-gram 范围 1-3,TFIDF 归一化 L2(C = 100,liblinear)。
  • 在测试集中,仇恨、冒犯和干净三类的精确率/召回率约在 0.94–0.98 范围内,冒犯召回率为 0.93,混淆矩阵显示有 4.8% 的冒犯推文被错误分类为仇恨。
  • 错误分析表明通过提升冒犯类召回率、减少仇恨误分类以及加入语言特征,可以带来改进。

更好的研究,从现在开始

从论文设计到论文写作,大幅缩短您的研究时间。

无需绑定信用卡

本解读由 AI 生成,并经人工编辑审核。