Back to Home GitHub Repo

Mood Classification using Spotify Audio Features

Can we detect the mood of a song without listening to it? This project uses Spotify audio features to classify songs as either 'happy' or 'not happy' based on valence score.

Dataset

Source: Spotipy

Size: 10,460 Spotify songs

I used a Spotify developer account along with Spotipy to retrieve the audio features from songs across several genres. I assigned a new mood variable to each song using the value for audio feature `valence` which represents how positive a song is (a score of 0 means the song is very sad, and 1 that the song is very happy). Below we can see how positivity of music has been changing over time.

Moods over time

Predicting Mood

Danceability and energy were key predictors of a song’s mood. Intuitively, we may think that happier songs have higher energy and danceability levels. This was reflected in our dataset as well.
Ultimately, we were able to predict whether a song was happy or not with 72% accuracy. In future projects, I can expand my predictions to mood levels instead of just 'happy' or 'not happy' in order create playlists or recommendations for users.

Tools & Libraries