In this work, I developed a tweet classification model to identify political affiliations in Spain by categorizing tweets into five distinct classes: Partido Popular (PP), Partido Socialista Obrero Español (PSOE), Ciudadanos, Podemos, and Vox. I tackled the challenge of discerning political discourse on social media, a crucial task for understanding public sentiment and the spread of political messages.
I experimented with three transformer-based models—RoBERTuito, BETO, and RoBERTa—each pre-trained on diverse linguistic and contextual datasets relevant to the Spanish language. I then fine-tuned these models on a labeled dataset of tweets that I manually classified according to their political alignment. After evaluating the results, I found that the best-performing model achieved a macro F1-score of 71% and an accuracy of 72%, which demonstrates the effectiveness of transformers in handling political text classification.