A 2024 University of Groningen group project classifying seven emotions in short English essays with TF-IDF features and Complement Naive Bayes.
Archive note
This README was refreshed in 2026 to document the project more clearly. The implementation and results remain from the original coursework.
- Lowercase the essays and remove punctuation, stop words, and non-alphabetic tokens.
- Split the course-provided training data into training and validation sets.
- Convert the cleaned text into count vectors and apply TF-IDF weighting.
- Train a Complement Naive Bayes classifier across anger, disgust, fear, joy, neutral, sadness, and surprise.
- Evaluate the saved model on a held-out test set of 270 essays.
The essays come from the WASSA 2023 Shared Task on empathy, emotion, and personality detection in reactions to news articles. The original task data was distributed through the WASSA competition page.
| Metric | Test result |
|---|---|
| Accuracy | 47.0% |
| Weighted F1 | 44.3% |
| Weighted precision | 44.7% |
| Weighted recall | 47.0% |
The class distribution is uneven, and sadness is both the largest class and the model's strongest category. The results are best read as an interpretable baseline and a practical lesson in evaluating classifiers under class imbalance.
python -m venv .venv
source .venv/bin/activate
pip install -r requirements.txt
python preprocessing/preprocessing.py
python model/NB_Train.py
python model/NB_Test.pyThe preprocessing step downloads the NLTK English stop-word list and rewrites the prepared CSV files. Training stores the classifier, vectorizer, and TF-IDF transformer in results/model_nb.pkl.
data/raw/contains the original course datadata/preprocessed/contains the cleaned training, validation, and test splitspreprocessing/contains the text-cleaning pipelinemodel/contains training and evaluation scriptsresults/contains the serialized model artifact
Built by Joris Postmus, Leon Tanis, and Joris Suurmeijer for the University of Groningen Natural Language Processing course.