Skip to main content
QUICK REVIEW

[Paper Review] MusicMood: Predicting the mood of music from song lyrics using machine learning

Sebastian Raschka|arXiv (Cornell University)|Nov 1, 2016
Music and Audio ProcessingComputer Science12 references10 citations
TL;DR

This paper proposes a naive Bayes classifier trained on song lyrics to predict whether music conveys a happy or sad mood, achieving 88.89% precision on a 200-song validation set. The system uses tf-idf feature vectors from preprocessed lyrics with n-gram and stemming techniques, demonstrating high precision for filtering happy music despite potential overfitting due to small dataset size.

ABSTRACT

Sentiment prediction of contemporary music can have a wide-range of applications in modern society, for instance, selecting music for public institutions such as hospitals or restaurants to potentially improve the emotional well-being of personnel, patients, and customers, respectively. In this project, music recommendation system built upon on a naive Bayes classifier, trained to predict the sentiment of songs based on song lyrics alone. The experimental results show that music corresponding to a happy mood can be detected with high precision based on text features obtained from song lyrics.

Motivation & Objective

  • To develop a machine learning model that predicts the mood of music based solely on song lyrics.
  • To create a new dataset of 2,773 lyrics labeled as 'happy' or 'sad' for mood prediction research.
  • To build a web application enabling real-time music mood prediction using artist and song title inputs.
  • To evaluate the performance of different text feature representations and preprocessing techniques for mood classification.
  • To explore the feasibility of using text-based sentiment analysis to filter music libraries for emotional tone.

Proposed method

  • A random subset of 10,000 songs was extracted from the Million Song Dataset, with lyrics collected from LyricWikia using artist and title metadata.
  • Non-English lyrics were filtered out by comparing English word counts to total word counts, retaining only songs with majority English content.
  • The final dataset of 2,773 songs was split into 1,000 training and 200 validation samples, with mood labels (happy/sad) assigned manually based on lyrical content and listening tests.
  • Text features were extracted using a bag-of-words model with n-grams (1–3), stop word removal, and Porter stemming, followed by binarization, term frequency (tf), and tf-idf vectorization.
  • Three naive Bayes models—multinomial and multivariate Bernoulli—were trained and evaluated using 10-fold cross-validation on the training set, with hyperparameter tuning via grid search.
  • The final model was retrained on the full training set and evaluated on the validation set, with performance measured using precision, recall, and ROC-AUC metrics.

Experimental results

Research questions

  • RQ1Can song lyrics alone be used to accurately predict the mood of music as happy or sad?
  • RQ2How do different text preprocessing techniques (e.g., stop word removal, stemming, n-gram size) affect mood classification performance?
  • RQ3What is the optimal feature representation (binarized, tf, or tf-idf) for mood prediction using naive Bayes on lyrical text?
  • RQ4To what extent does model overfitting occur when training on a small dataset with high-dimensional feature spaces?
  • RQ5Can a high-precision mood classifier be built to filter out sad songs with minimal false positives for practical music recommendation systems?

Key findings

  • The multinomial naive Bayes classifier with tf-idf feature representation achieved the highest ROC-AUC score, outperforming both Bernoulli and tf-based models.
  • Stop word removal consistently improved model performance across all configurations, indicating that common words reduce predictive signal for mood.
  • The model achieved 99.60% precision on the training set and 88.89% precision on the 200-song validation set, suggesting a risk of overfitting due to small dataset size and extensive hyperparameter tuning.
  • Increasing n-gram size beyond unigrams negatively impacted performance, with 1-grams yielding the best results across all configurations.
  • The word cloud visualization revealed that non-relevant, common words were prevalent in both happy and sad songs, justifying the use of tf-idf to suppress such terms.
  • The model's high precision supports its use as a reliable filter to exclude sad music from large music libraries prior to further processing like genre classification.

Read this paper

Open the full text in the Nubint reader and ask about any passage as you read.

Read this paper on Nubint

This review was generated by AI from the original paper. Please check the paper before citing it.