Classification Model of Emotional Tone in Hate Speech and Its Relationship with Inequality and Gender Stereotypes, Using NLP and Machine Learning Algorithms

Hate speech on social media reproduces norms of inequality and gender stereotypes, disproportionately affecting women. This study proposes a hybrid approach that integrates emotional tone classification with explicit hostility detection to strengthen preventive moderation. We constructed a corpus from three open datasets (1,236,371 records; 1,003,991 after ETL) and represented the text using TF-IDF and contextual RoBERTa embeddings. We trained individual models (RoBERTa fine-tuned, Random Forest, and XGBoost) and a stacking metamodel (Gradient Boosting) that combines their probabilities. On the test set, the ensemble outperformed the base classifiers, achieving accuracy of 0.93 in hate detection and 0.90 in emotion classification, with an AUC of 0.98 for emotion classification. We implemented a RESTful API and a web client to validate the moderation flow before publication, along with an administration panel for auditing. Performance tests showed viability under moderate loads and concurrency limitations starting at 300 users, associated with deployment via an Ngrok tunnel. In general, the results indicate that incorporating emotional tone analysis improves the model’s ability to identify implicit hostility and offers a practical way to promote safer digital environments. The probabilistic results obtained by the ensemble model were subsequently analyzed using the Bayesian Calibration and Optimal Design under Asymmetric Risk (BACON-AR) framework, which serves as a mathematical post-hoc validation layer to optimize the decision threshold under unequal costs. This framework does not modify the trained architecture but adjusts the estimated probabilities and selects the threshold that minimizes the total expected risk. By combining TF-IDF and RoBERTa embeddings with a stacked metamodel, the ensemble’s decision function was optimized via regularization, improving generalizability and the stability of predictions. The incorporation of the BACON-AR framework strengthened the system’s probabilistic consistency, ensuring that final decisions were aligned with the actual consequences of errors under an asymmetric risk scheme.

Liked Liked