This study investigates the use of machine learning to detect racial and ethnic bias in social media posts using TF-IDF text embeddings and multiple classification models. Results show that Random Forest achieved the highest overall accuracy of 93.45%, demonstrating the potential of machine learning to support automated bias detection despite challenges posed by imbalanced data and the complexity of language.
Social media platforms contain large amounts of user-generated content, making it difficult for humans to identify harmful language manually. This project investigates whether machine learning can be used to detect racial and ethnic bias in social media posts. The dataset used was Hate Speech and Bias against Asians, Blacks, Jews, Latines, and Muslims: A Dataset for Machine Learning and Text Analytics, which contains 5,880 labeled tweets collected between 2020 and 2022. Several machine learning models were trained and evaluated using TF-IDF (Term Frequency-Inverse Document Frequency) text embeddings, including K-Nearest Neighbors (KNN), Random Forest, Multi-Layer Perceptron (MLP), AdaBoost, and Support Vector Classification (SVC). Random Forest achieved the highest accuracy (93.45%) and precision (57.14%), while the Multi-Layer Perceptron achieved the highest recall (11.54%) and F1 score (0.141). These findings suggest that machine learning can assist in detecting racial and ethnic bias in social media posts, although performance remains limited due to the imbalanced dataset and the complexity of language.
Related Projects