Ensemble_Text_Classification_with_TF-IDF_Vectorization_for_Hate_Speech_Detection_in_Social_Media
Ensemble_Text_Classification_with_TF-IDF_Vectorization_for_Hate_Speech_Detection_in_Social_Media
Abstract—The development of artificial intelligence (AI) findings in order to get over these restrictions.
has changed how hate speech is detected. In hate speech Ensemble approaches have become a potent ML
identification using machine learning, a number of methods are strategy for enhancing predicting performance in recent
used to automatically find text that uses vocabulary that is years. To arrive at a decision, ensemble approaches integrate
considered to be derogatory, discriminatory, or motivated by
the predictions of various separate classifiers. It is possible
hatred. Supervised learning techniques like neural networks,
decision trees, and SVMs need a labelled dataset comprising to more effectively identify and categorise hate speech on
samples of hate speech and non-hate speech. This project social media by utilising ensemble methods for text
investigates the use of AI and machine learning techniques to classification.
automatically detect material that uses offensive, intolerant, or In this study, we use ensemble text categorization
hostile words. A voting classifier and TF-IDF representations algorithms to address the problem of hate speech on social
are combined to improve classification accuracy. The ensemble media. Our suggestion is to use a voting classifier, which
of classifiers, powered by AI approaches, shows impressive combines the predictions of different classifiers trained on
accuracy in identifying hate speech by training five different TF-IDF vectorized text data. The ensemble includes
classifiers (Random Forest, Bagging, Support Vector Machine,
classifiers with different strengths and characteristics, such
AdaBoost, and Gradient Boosting) on a labelled dataset of
tweets. The TF-IDF representation prioritises textual terms, as Random Forest, Bagging, Support Vector Classifier
whereas the ensemble method uses classifier diversity to (SVC), AdaBoost, and Gradient Boosting. To capture
capture distinctive patterns. Results from experiments show numerous aspects and patterns of hate speech in textual data,
the strategy's effectiveness, with precision 0.95, recall 0.96, f1- we can use ensemble approaches to take advantage of the
score 0.95 and accuracy 0.97 for detecting hate speech. By diversity of these classifiers. The textual data can also be
successfully utilising AI's capacity to fight hate speech, this represented quantitatively thanks to the TF-IDF
research helps the development of a diverse and secure online vectorization technique, giving us important new insights
environment. The suggested approach works well for into the significance of phrases in hate speech identification.
automatically identifying hate speech, making the internet a
safer and more welcoming place for all users.
The long-term objective of this research is to aid in the
creation of an automated system for detecting hate speech
Keywords— Hate Speech, Machine learning, SVM, Naive on social media sites. We want to build a more precise and
Bayes, Random Forest Classifier, Stochastic Gradient Descent, reliable system that can efficiently identify and suppress
Decision Tree Classifier. hate speech in real-time by using ensemble approaches and
making use of developments in natural language processing
I. INTRODUCTION (NLP). The results of this study will help social media
Social media networks (SMNs) have transformed service providers as well as researchers lessen the negative
communication by enabling the quick interchange of ideas effects of hate speech and promote a secure online
and information. However, the widespread use of SMNs has environment.
also given rise to certain worrying problems, such the
propagation of hate speech. The safety and wellbeing of
users are seriously threatened by the fact that hate speech on
various social media has turned into a breeding ground for
hate-motivated online crime. Thorough study and novel
strategies are needed to address the rise in hate speech
events on these platforms. The enormous amount of text
data that needs to be processed and categorised is one of the
main obstacles in the fight against hate speech on social
media. Such data must be manually processed and classified,
which takes time and is subject to biases driven by human
factors like competence and fatigue. Automating text
categorization processes using machine learning (ML) Figure 1: Hate Speech
techniques is necessary to get more accurate and objective
[4] CNN0,CNN1, CNN2 0.753 0.712 -- -- Bias and fairness robustness to new data and
variations.
[5] BoW+TF +Word2Vec ALO 0.721 0.701 -- 0.707 Data availability and quality Interpretability and
explainability.
[6] SVM+TF-IDF weights -- 0.985 -- -- Language dependency generalizability.
[7] MTL sent + emo -- 0.921 0.902 0.936 Dataset is very limited and complex model
architecture requiring substantial computational
resources.
[8] BERT -- 0.924 0.93 0.92 Model selection interpretability.
[9] Emotion Analysis using binary -- 0.5406 0.606 0.0487 Lack of human annotation reliance on external
values and the emotion from tools.
VADER with three scores
[10] Bi-LSTM + attention 0.875 0.884 0.892 0.883 Lack of comparison with baseline limited
preprocessing techniques and limited embedding
models.
[14] Lexical Rule Based -- 0.7 0.73 0.73 Challenges with dynamic language potential bias
and subjectivity.
[15] Logistic Regression with L -- 0.906 0.9 0.9 The hate speech lexicon may not capture all
regularization forms of hate speech or adapt well to evolving
language usage.
III. METHODOLOGIES
SVC (Support Vector Classifier) divides the data into
The dataset used consists of labelled examples of
distinct groups using a hyperplane. Both the
tweets that were collected from a variety of sources,
AdaBoostClassifier and the GradientBoostingClassifier
including online social networks and freely accessible
are boosting techniques that combine weak learners to
hate speech datasets. Instances of both hateful and non-
create a strong classifier. AdaBoost concentrates on
hateful content are included in the dataset, which has been
challenging examples by giving instances that were
thoroughly filtered. Every instance receives a label
incorrectly classified a higher weight, while Gradient
designating whether it is hate speech (label 1) or not (label
Boosting builds weak learners in a sequential fashion to
0), with 1 denoting that it is. The ensemble classifier is
correct errors made by earlier learners.
trained using the training set, and its performance is
Predictions are made for the testing data using the
assessed using the testing set. The Voting Classifier class
predict technique after the ensemble classifier has been
from scikit-learn was used to generate the ensemble
trained using the fit approach on the training data. Some
classifier, which combines the predictions of various basic
of the metrics are used to evaluate the performance of the
classifiers to produce the final prediction. Random Forest
ensemble classifier. These metrics reveal the classifier's
Classifier, Bagging Classifier, SVC, AdaBoostClassifier,
ability to correctly classify instances and achieve a
and Gradient Boosting Classifier are the base classifiers
balance between recall and accuracy.To improve the
utilised in this code. A Tfidf Vectorizer step and a
performance of the ensemble classifier, distinct base
classification algorithm step make up each base classifier's
classifiers can be switched out for others using various
implementation as a Pipeline object. The input text is
techniques or iterations. Using hyper parameter tuning
transformed into numerical features using the Term
approaches, the classifiers' parameters may also be
Frequency-Inverse Document Frequency (TF-IDF)
adjusted for better performance and customisation.
technique in the Tfidf Vectorizer stage. The TF-IDF
measures the relative relevance of phrases by giving them A. Random Forest Classifier
weights based on their frequency in a document and
inverse frequency across all documents. The classifiers
Depending on the implementation, the function of the
can now deal with numerical data instead of plain text
Random Forest Classifier, a potent machine learning
thanks to this change. Each base classifier uses converted
technique. As one of the foundation classifiers in the
numerical characteristics in the classification algorithm
ensemble technique, the Random Forest Classifier[21] is
step to classify the data using methods unique to that
crucial to our investigation. It contributes to the
classifier. The RandomForestClassifier builds a group of
development of the ensemble classifier, which tries to
decision trees and averages or votes on each one's
improve the overall predictive performance, by merging
predictions to aggregate them. By bootstrapping subsets of
various decision trees. A random portion of the training
the training data, the BaggingClassifier reduces variance
data and a random selection of features are used to build
and boosts stability by training different classifiers on
each decision tree in the Random Forest Classifier. This
each subset. To maximise the gap between classes, the
F. TF-IDF Vectorization
TABLE II: Performance metrics of Different algorithms. V. DISCUSSION AND FUTURE WORKS
Precision Recall F1 Accuracy It is possible to identify challenges in the detection of
Algortihm hate speech based on earlier publications after analysing
Score Score Score Score
the research. It takes more than keyword searches to
Bi-LSTM successfully identify hate speech, which is a difficult
0.883 0.892 0.884 0.875 undertaking. On the basis of the review that was
+Attention
completed in the previous part, we may identify a few
research issues in the automated identification of hatred in
BoW + social media. Will we be able to distinguish between
Word2Vec 0.707 -- 0.701 0.721 diverse settings of hate speech for other cultures? This is
ALO
one of the issues from a social and political perspective.
Enssemble Hate speech detection is a multidisciplinary subject that
Model 0.9567 0.9692 0.9537 0.9792 requires consideration from a range of viewpoints. Taking
Classifier into account that there is no consensus, constitutes for
detecting hate speech or sentiment analysis. Along with
The table shows that in terms of precision, recall, F1 the legitimacy concern, it might be challenging to
score, and accuracy score, the Ensemble Model Classifier distinguish between serious and trivial cases because hate
fared better than the other methods. It obtained scores of 0 speech has a variety of manifestations and occasionally
.9567 for precision, 0.9592 for recall, 0.9537 for F1, and 0 refers to or is included in them. Choosing the optimal
.9592 for accuracy . These findings demonstrate how the machine learning approach is a challenging decision from
ensemble method can enhance the overall efficiency of a technical perspective. Most techniques from earlier
hate speech detection models. On the other hand, the Bi- works were used. Most researchers employed supervised
LSTM + Attention algorithm also demonstrated machine learning methods for their task of automatic
competitive performance , earning scores of 0.883 for detection. The least popular methods are semi-supervised
precision , 0.892 for recall , 0.884 for F1, and 0.875 for ones, which are followed by unsupervised methods in
accuracy .With precision and accuracy ratings of 0.707 terms of popularity. Consideration must be given to all
and 0.721 , respectively , the BoW + Word 2Vec ALO factors that could affect our choice of the optimal course
method fared less well than the other two algorithms. The of action. Because some ML algorithms work well with
recall score for this method, however, is not available for little datasets, the corpus size is one key factor to take into
our investigation .These results emphasise the importance account.
of using the right algorithm to detect hate speech on social
media. The Ensemble Model Classifier demonstrates how VI. CONCLUSION
the ensemble approach may significantly improve the This paper reviews past investigations into the
performance of the detection model , achieving prevalence of hate speech across many media platforms,
outstanding precision , recall , F1 score , and accuracy . In including online social networks. As more people turn to
general our comparison evaluation shows how successful the internet to express their intolerance and hatred for a
the ensemble technique is at detecting hate speech and particular group of people, hate speech has been rising
sheds light on how other algorithms perform . These quickly around the world. Hate speech has grown to be a
findings expand hate speech identification methods and powerful catalyst for inciting violence and furthering
can aid academics and professionals in choosing the right nefarious political goals and intentions, which is a major
algorithms for specific purposes. cause for concern. Therefore, it is urgent that hate speech
be identified and stopped before it spreads on social
media in various forms, including audio, video, and
images. Our methodology, which will be described in
more detail in the future, was identified and realised for
this purpose through an in-depth analysis of previous
studies. We further find out that the SVM performs
overall under the topic of Accuracy and Precision.
Consider using a variety of ensemble methods and larger
datasets to improve the accuracy and robustness of hate
speech identification. Address the difficulties associated
with identifying hate speech in many cultural contexts,
and make use of sophisticated NLP approaches, such as
deep learning and attention mechanisms, to capture
Fig 3 Graphical comparison of proposed method with other intricate linguistic patterns. These methods seek to
algorithm improve the identification of hate speech and establish
safer online settings.The ensemble method gives overall
This bar graph contrasts the accuracy, F1, recall, and accuracy over 95%. Several tactics can be used to
precision scores for the overall approach we trained the improve the ensemble classifier's efficiency in detecting
model using. hate speech. These include expanding the ensemble size
to enhance generalisation and enhancing ensemble
diversity by utilising various techniques, feature sets, or
[5] C. Baydogan and B. Alatas, "Metaheuristic Ant Lion and [18] C. Baydogan, ‘‘Deep-Cov19-hate: A textual-based novel
Moth Flame Optimization-Based Novel Approach for approach for automatic detection of hate speech in online
Automatic Detection Hate Speech in Online Social social networks throughout COVID-19 with shallow and
Networks," in IEEE Access, vol. 9, pp. 110047-110062, deep learning models,’’ Tehnički Vjesnik, vol. 29, no. 1,
2021, DOI: 10.1109/ACCESS.2021.3102277. pp. 149–156, 2022
[6] M. Z. Ali, Ehsan-Ul-Haq, S. Rauf, K. Javed, and S. Hussain, [19] S. Jaki and T. De Smedt, ‘‘Right-wing German hate speech
"Improving Hate Speech Detection of Urdu Tweets Using on Twitter: Analysis and automatic detection,’’ 2019,
Sentiment Analysis," in IEEE Access, vol. 9, pp. 84296- arXiv:1910.07518.
84305, 2021, DOI: 10.1109/ACCESS.2021.3087827.
[20] M. Di Capua, E. Di Nardo, and A. Petrosino,
[7] F. M. Plaza-Del-Arco, M. D. Molina-González, L. A. ‘‘Unsupervised cyber bullying detection in social
UreñaLópez and M. T. Martín-Valdivia, "A Multi-Task networks,’’ in Proc. 23rd Int. Conf. Pattern Recognit.
Learning Approach to Hate Speech Detection Leveraging (ICPR), Dec. 2016, pp. 432–437.
Sentiment Analysis," in IEEE Access, vol. 9, pp. 112478-
112489, 2021, DOI: 10.1109/ACCESS.2021.3103697. [21] P. Badjatiya, S. Gupta, M. Gupta, and V. Varma, ‘‘Deep
learning for hate speech detection in tweets,’’ in Proc. 26th
[8] H. S. Alatawi, A. M. Alhothali, and K. M. Moria, Int. Conf. World Wide Web Companion (WWW
"Detecting White Supremacist Hate Speech Using Domain- Companion), 2017, pp. 759–760
Specific Word Embedding With Deep Learning and
BERT," in IEEE Access, vol 9, pp. 106363-106374, 2021, [22] I. Mollas, Z. Chrysopoulou, S. Karlos, and G. Tsoumakas,
DOI: 10.1109/ACCESS.2021.3100435. ‘‘ETHOS: An online hate speech detection dataset,’’ 2020,
arXiv:2006.08328.
[9] A. Rodriguez, Y. -L. Chen and C. Argueta, "FADOHS:
Framework for Detection and Integration of Unstructured
Data of Hate Speech on Facebook Using Sentiment and
Emotion Analysis," in IEEE Access, vol. 10, pp. 22400-
22419, 2022, DOI: 10.1109/ACCESS.2022.3151098.