Hate Speech Detection on Twitter Using XGBoost: A Large-Scale Dataset Analysis with Feature Engineering and Comparative Evaluation
Social media platforms and Twitter in particular, has become a fertile channel for the rapid circulation of harmful discourse, including hateful and offensive language aimed at individuals and communities. Automatically flagging such content remains a demanding task within natural language processing, largely because micro blog text is short, informal, and heavily reliant on context for correct interpretation. This paper presents a hate-speech classification framework built around the Extreme Gradient Boosting (XGBoost) algorithm and evaluated on one of the largest publicly available labeled Twitter corpora, comprising roughly 96,973 tweets divided into three categories: hate speech, offensive language, and normal content. Each tweet is represented through a combined set of feature families: Term Frequency-Inverse Document Frequency (TF-IDF) vectors, dense word-embedding features, and tweet-level metadata such as hash tag frequency, mention count, re tweet count, and capitalization ratio. Prior to feature extraction, tweets are cleaned through tokenization, stop-word removal, lemmatization, and URL stripping to reduce noise in the raw corpus. The hyper parameters of the XGBoost classifier were selected through grid search combined with stratified cross-validation. The tuned model reached an overall accuracy of 93.7%, a macro-averaged F1-score of 0.937, and an area under the curve above 0.94 for every class, surpassing the results obtained with Naive Bayes (78.4%), Support Vector Machines (82.1%), Random Forest (85.6%), LSTM networks (88.3%), and a fine-tuned BERT model (90.1%). These outcomes indicate that gradient boosting, when paired with a carefully engineered feature set, provides an accurate and computationally efficient alternative for large-scale hate-speech detection.
Paper
The full text of this publication is not hosted on 44B due to licensing.
Read it at OpenAlex