Music Mood Prediction Based on Spotify's Audio Features

Dashboard A project from DATA 602 course at Drew University.

Link access to my colab notebook

Have you ever noticed how certain music instantly changes your mood? It’s no secret that music has a powerful effect on our emotions. And with the rise of music streaming services like Spotify, we have access to more music than ever before.

This project is inspired by Spotify’s “Wrapped” feature, which provides insights into your listening habits throughout the year. It made me wonder if I could use the data provided by Spotify to predict the mood of a song based on its audio features.

In this post, I will discuss the process of developing a music mood prediction model using Spotify’s audio features. I will also share the results of my experiments and discuss the potential applications of this technology.

Why Music Mood Prediction?

There are many potential applications for music mood prediction technology. For example, it could be used to:

Create personalized music recommendations based on your current mood.

Develop music-based mood regulation therapies.

Improve the performance of music search engines.

Create interactive music experiences that adapt to your mood.


I was motivated to work on this project because I believe that music has a powerful impact on our moods and emotions. I wanted to see if I could use technology to harness this power and create a tool that could help people improve their well-being. Analyzing data for exploratory tasks felt like a business-focused Spotify Wrapped experience. While Spotify shows your top genres and artists, Tableau unveiled fascinating trends and patterns hidden within the numbers. Data and Methodology

Dataset contains 1254 songs with 26 features.

matrix In this project, I used data from the Spotify and a third website party. The API provides access to a variety of data about songs, including their audio features, lyrics, and popularity.

I used the audio features to train a machine learning model to predict the mood of a song. The audio features include:

Acousticness: A confidence measure from 0.0 to 1.0 of whether the track is acoustic.

Danceability: Measures how suitable a track is for dancing based on a combination of musical elements including tempo, rhythm stability, beat strength, and overall regularity.

Energy: The overall energy of a track.

Instrumentalness: Predicts whether a track contains no vocals.

Liveness: Detects the presence of an audience in the recording.

Loudness: The overall loudness of a track in decibels (dB).

Speechiness: The presence of spoken words in a track.

Tempo: The overall tempo of a track in beats per minute (BPM).

Time_signature: The time signature of a track.

Valence: A measure of how positive or negative a track is. radar chart I trained the model using a variety of machine learning algorithms, including logistic regression, random forest, Gaussian Naive Bayes, and K-Nearest Neighbors applied within pipelines.

  • Cluster 0: This cluster seems to represent music that is relatively upbeat and energetic. The high median BPM (105.50%) suggests a faster tempo. Danceability (105.50%) and Energy (58%) are quite high, indicating these tracks might be good for dancing or more dynamic activities.
  • Cluster 1. This cluster likely represents slower, more acoustic, and instrumental tracks. The lower BPM (97%) suggests a slower tempo. High Acoustic (98%) and Instrumental (90%) values reinforce this interpretation. Danceability (36%) and Energy (11%) are much lower compared to Cluster 0, suggesting these tracks might be more suitable for relaxed or contemplative settings.
  • Cluster 2: Danceability (50%) and Energy (36%) are moderate, making these tracks potentially versatile for different settings with a good balance of acoustic elements (78.50%). A relatively high, indicating a significant presence of acoustic elements.



Random forest:

Random forest

Gaussian Naive Bayes: Gaussian Naive Bayes

Logistic regression: Logistic regression