polito.it
Politecnico di Torino (logo)

Decoding Dreams and Thoughts using AI Sentiment Analysis

Mahdi Hasanzadeh

Decoding Dreams and Thoughts using AI Sentiment Analysis.

Rel. Valeria Chiado' Piat, Vito De Feo. Politecnico di Torino, Corso di laurea magistrale in Data Science And Engineering, 2025

[img] PDF (Tesi_di_laurea) - Tesi
Licenza: Creative Commons Attribution Non-commercial No Derivatives.

Download (5MB)
Abstract:

Understanding and classifying the emotional content of dream descriptions is a unique challenge that sits between psychology and natural language processing. This thesis tackles this issue by creating a machine learning pipeline that can automatically predict sentiment labels from free-text dream narratives. The main method uses handcrafted lexical-semantic features for sentiment classification. Specifically, Term Frequency–Inverse Document Frequency (TF-IDF) extracts lexical patterns, while Empath, a psychologically grounded lexicon, provides high-level semantic signals. To address extreme class imbalance in the labeled data, a targeted resampling strategy based on SMOTE is used to ensure balanced representation across all sentiment categories. A Multi-Layer Perceptron (MLP) classifier is trained on the engineered features and evaluated using both 5-fold stratified cross-validation and Leave-One-Out Cross-Validation (LOOCV). The model achieves a high accuracy of 86\% and strong macro F1-scores across folds and samples. This shows robust generalization with minimal overfitting. In addition to this main pipeline, the thesis also looks into fine-tuning large language models. A DeBERTa transformer was adapted using parameter-efficient LoRA (Low-Rank Adaptation), allowing for modeling emotional language in context. Although this was not integrated into the main system, this parallel investigation highlights the potential of transformer-based models for understanding emotions in narrative text. Beyond model performance, the thesis examines how consistent the sentiment labels are by comparing multiple sources. Cross-dataset accuracy matrices and correlation analyses (Cohen’s Kappa and Spearman’s rho) show significant disagreements among annotators. This highlights the subjective nature of emotional labeling in dreams. Overall, this work provides a reproducible affective computing pipeline for narrative data and offers insights into the challenges of subjectivity in human-labeled sentiment datasets, especially in areas like dream interpretation.

Relatori: Valeria Chiado' Piat, Vito De Feo
Anno accademico: 2025/26
Tipo di pubblicazione: Elettronica
Numero di pagine: 70
Soggetti:
Corso di laurea: Corso di laurea magistrale in Data Science And Engineering
Classe di laurea: Nuovo ordinamento > Laurea magistrale > LM-32 - INGEGNERIA INFORMATICA
Aziende collaboratrici: University of Essex
URI: http://webthesis.biblio.polito.it/id/eprint/37830
Modifica (riservato agli operatori) Modifica (riservato agli operatori)