Dataset Viewer
Auto-converted to Parquet Duplicate
Search is not available for this dataset
image
imagewidth (px)
784
2.59k

🎡 What Makes a Hit Song? β€” Spotify EDA

Assignment #1 β€” EDA & Dataset | March 2026


πŸ“½οΈ Video Presentation


πŸ“Œ Overview

This project explores the 30,000 Spotify Songs dataset to answer one core question:

How do audio features β€” danceability, energy, loudness, speechiness, tempo, acousticness, instrumentalness, liveness, valence, and duration β€” affect the popularity of a song?

The goal is to identify the optimal range of audio features that music producers should aim for to increase the chances of their song becoming a hit.


πŸ“‚ Dataset

Property Details
Source Kaggle β€” 30000 Spotify Songs
Raw Size 32,833 rows Γ— 23 features
Final Size 32,790 rows Γ— 25 features (after cleaning, feature engineering & column pruning)
Target Variable track_popularity (0–100)
Hit Definition track_popularity > 75 (top ~8.1% of all tracks)

Audio Features Explained

Feature What It Means Example
danceability How easy it is to dance to (0.0–1.0) Low = slow ballad, High = club banger
energy Perceptual intensity and activity (0.0–1.0) Death metal = high, Bach prelude = low
loudness Average loudness in decibels (dB) Closer to 0 = louder, βˆ’60 = almost silent
speechiness Presence of spoken words (0.0–1.0) >0.66 = mostly speech, <0.33 = music
acousticness Confidence that a track is acoustic (0.0–1.0) Guitar unplugged = high, EDM synths = low
instrumentalness Likelihood the track has no vocals (0.0–1.0) Jazz instrumental = high, pop singer = low
liveness Presence of a live audience (0.0–1.0) >0.8 = likely live recording
valence Musical positiveness (0.0–1.0) Happy/cheerful = high, sad/angry = low
tempo Estimated tempo in BPM 60 BPM = slow, 180 BPM = very fast
duration_min Song length in minutes 2 min = short, 6 min = long

πŸ› οΈ Setup

from google.colab import drive
import pandas as pd
import numpy as np
import matplotlib.pyplot as plt
import seaborn as sns

Developed in Google Colab with the dataset loaded from Google Drive.


🧹 Data Cleaning

Missing Values: Found 5 rows with missing track_name, track_artist, and track_album_name β€” all removed.

Duplicates: None found β€” no action needed.

Impossible Values:

  • tempo = 0 BPM β†’ dropped (1 track). A song with 0 BPM cannot exist.
  • loudness > 0 dB β†’ dropped (6 tracks). Industry standard caps loudness at 0 dB.

Final shape after cleaning: (32,790, 23)


βš™οΈ Feature Engineering

Three new features were created:

  • release_year β€” extracted from track_album_release_date (covers 1957–2020)
  • is_hit β€” True if track_popularity > 75 (top ~8.1% of tracks by popularity score)
  • loudness_scaled β€” loudness rescaled from dB (βˆ’60 to 0) to a 0–100 range for readability
  • duration_min β€” changed duration ms to duration in min.

πŸ—‘οΈ Column Pruning

Two columns were intentionally dropped after feature engineering:

  • track_album_release_date β€” used only to derive release_year. Once extracted, the original date string is redundant.
  • playlist_subgenre β€” all genre analysis operates at the broad playlist_genre level. This column was never computed, visualized, or referenced.

Final dataset shape: (32,790, 25)


πŸ“Š Visualizations & Key Findings

1. Outlier Detection β€” All 10 Audio Features

Outlier Detection

Box plots across all 10 features reveal the spread and outliers in the dataset. Key observations:

  • Tempo clusters tightly between 100–130 BPM
  • Instrumentalness is nearly flat near 0 β€” ~90% of tracks have vocals
  • Speechiness & Liveness are heavily right-skewed β€” most tracks are studio recordings with minimal spoken word
  • Valence is evenly spread, reflecting a healthy mix of happy and sad music

All outliers were kept β€” extreme values (e.g. 10-min songs, instrumental tracks) are valid artistic choices, not data errors.


2. Hit Rate Threshold Sensitivity

Hit Rate Threshold

To define "hit" objectively, every threshold from 60 to 85 was tested. Results:

Threshold Hit Rate Decision
60 27.2% Too generous β€” over a quarter of songs can't all be hits
65 20.1% Still too broad
70 13.5% Getting closer
75 8.1% βœ… Selected β€” meaningful minority, large enough to analyze
80 4.1% Too strict β€” loses too much signal
85 1.9% Only mega-hits qualify

Threshold = 75 was selected as the sweet spot.


3. Popularity Distribution & Hit/Non-Hit Split

Popularity Distribution

The popularity distribution shows a natural drop-off above 70, confirming that 75 sits right at the edge of the top tier. Result: 2,657 hits (8.1%) vs 30,133 non-hits (91.9%). For every 1 hit, there are ~11 non-hit songs.


4. Hits vs Non-Hits β€” Median Feature Comparison

Median Comparison

All 10 features normalized to 0–1 and compared between hits and non-hits:

  • ↑ Danceability β€” hits score consistently higher. Groove matters.
  • ↑ Loudness β€” hits are louder. Tight mastering is industry standard.
  • ↑ Acousticness β€” hits have a slightly more organic sound.
  • ↑ Valence β€” hits trend happier. Feel-good music has a streaming edge.
  • ↓ Speechiness β€” hits are more melodic, less spoken-word.
  • ↓ Instrumentalness β€” hits almost always have vocals.
  • ↓ Liveness β€” hits are studio recordings, not live performances.
  • ↓ Tempo β€” hits are slightly slower (~118 BPM vs ~122 BPM average).
  • ↓ Duration β€” hits are shorter. Streaming rewards conciseness.
  • ~ Energy β€” similar between groups; hits are slightly lower in energy.

5. Correlation Heatmap β€” All Audio Features

Correlation Heatmap

Key relationships revealed by the heatmap:

  • Energy ↔ Loudness (r = +0.68) β€” the strongest link. Louder songs almost always feel more energetic.
  • Energy ↔ Acousticness (r = βˆ’0.54) β€” acoustic tracks feel calmer and less intense.
  • Loudness ↔ Acousticness (r = βˆ’0.36) β€” louder songs are less acoustic.
  • Danceability ↔ Valence (r = +0.33) β€” happier songs tend to be more danceable.
  • Instrumentalness ↔ Popularity (r = βˆ’0.15) β€” the clearest predictor: vocals = popularity.
  • Duration ↔ Popularity (r = βˆ’0.14) β€” shorter songs perform better.

All other features vs popularity show correlations below 0.10 β€” no single feature is a magic predictor on its own.


6. Audio Features vs Track Popularity β€” Scatter Plots

Scatter Plots

Each feature plotted against popularity with a linear trend line (r values shown):

  • Instrumentalness (r = βˆ’0.15) and Duration (r = βˆ’0.14) show the clearest negative trends.
  • Acousticness (r = +0.09) is the strongest positive predictor β€” a touch of organic sound helps.
  • Tempo (r β‰ˆ 0.00) is essentially flat β€” tempo alone does not drive popularity.
  • Energy, Speechiness, Liveness, Valence all show weak but directionally consistent trends.

7. Music Trends Over Time

Music Trends Over Time

Hit rates peaked in the mid-1960s (~17%) and surged again post-2015, reaching ~14% by 2019.

Why recent songs score higher: Spotify's popularity score is recency-weighted β€” it favors tracks with recent, high-volume streaming activity over all-time totals. Combined with the viral amplification of social media (TikTok, Instagram Reels), newer songs accumulate streams far faster than songs from previous decades could. This is a measurement artifact, not evidence that modern music is objectively better.


8. Songs count per year.

Music Trends Over Time

Clearly shows a difference in amount of data per each year.

9. Hit Ratio by Genre

Hit Ratio by Genre

Genre Hit Ratio Notes
Pop 0.157 Nearly double the overall average β€” designed for mass appeal
Latin 0.138 Strong global wave (Bad Bunny, J Balvin) shows in the data
R&B 0.098 Above average β€” loyal streaming audience
Rap 0.060 Below average
EDM 0.044 Lowest β€” EDM success lives in festivals, not Spotify streams

10. Sweet Spot by Genre β€” KDE Analysis

Sweet Spot by Genre

KDE plots showing where hit songs cluster for Pop, Latin, and R&B across all 10 features:

Universal across all genres:

  • High energy (0.6–0.8), high loudness, near-zero instrumentalness and speechiness, low liveness, short duration (3–4 min)

Genre-specific differences:

  • Tempo: Pop/R&B peak at 95–125 BPM; Latin shows a second peak at ~175 BPM (reggaeton)
  • Danceability: Latin requires the highest (~0.78), R&B allows more variation
  • Valence: Pop and Latin lean happier; R&B spans a wider emotional range
  • Acousticness: R&B allows more organic elements than Pop

βœ… Summary & Conclusions

General range for popular music

Feature Direction Hit Sweet Spot
Danceability ↑ positive 0.70–0.85
Energy ~ neutral 0.60–0.80
Loudness ↑ positive 85–90 (scaled)
Speechiness ↓ negative < 0.10
Tempo ~ irrelevant Genre-dependent
Acousticness ↑ slight positive Slightly above average
Instrumentalness ↓ strong negative ~0.0 (vocals essential)
Liveness ↓ negative < 0.15 (studio only)
Valence ↑ slight positive Slightly above average
Duration ↓ negative 3–4 minutes

Genre Sweet Spot Tables β€” Producer Cheat Sheet

Based on the KDE analysis of hit songs in each of the top 3 genres, here are the optimal feature ranges:

🎀 Pop

Feature Sweet Spot Notes
Danceability 0.65–0.80 High but not extreme β€” steady groove
Energy 0.60–0.85 Energetic, radio-ready feel
Loudness (scaled) 85–90 Loud, compressed mastering
Speechiness < 0.10 Melody-first β€” minimal spoken word
Tempo 95–130 BPM Standard pop range
Acousticness 0.05–0.25 Mostly produced, slight organic touch
Instrumentalness ~0.00 Vocals are essential
Liveness < 0.15 Studio production only
Valence 0.40–0.75 Leans happy and upbeat
Duration 3.0–3.8 min Short, replayable tracks

πŸ’ƒ Latin

Feature Sweet Spot Notes
Danceability 0.75–0.85 Highest of all genres β€” dance is mandatory
Energy 0.60–0.85 High energy, rhythm-driven
Loudness (scaled) 85–90 Same loud standard as pop
Speechiness < 0.10 Singing over speaking
Tempo 95–105 or 170–200 BPM Bimodal β€” slow reggaeton and fast salsa/cumbia
Acousticness 0.10–0.35 Slightly more organic than pop
Instrumentalness ~0.00 Always vocal
Liveness < 0.15 Studio recordings dominate
Valence 0.50–0.80 Happy, feel-good energy
Duration 3.0–4.0 min Streaming-friendly length

🎢 R&B

Feature Sweet Spot Notes
Danceability 0.60–0.80 Wider range β€” groove matters but isn't everything
Energy 0.50–0.75 Slightly lower β€” allows smooth, mellow tracks
Loudness (scaled) 80–90 A touch softer than pop/Latin
Speechiness < 0.15 Slightly higher tolerance (rap-influenced R&B)
Tempo 95–125 BPM No second peak β€” steady mid-tempo
Acousticness 0.10–0.45 Most acoustic-friendly genre β€” organic sound welcome
Instrumentalness ~0.00 Vocals remain essential
Liveness < 0.15 Studio quality standard
Valence 0.25–0.70 Widest emotional range β€” moody and happy both work
Duration 3.0–4.2 min Slightly longer than pop is acceptable

Bottom line: High energy, loud mastering, vocals, and 3–4 minutes are universal. The real genre fingerprint lives in tempo (Latin's bimodal peaks), danceability (Latin demands the most), acousticness (R&B allows the most), and valence (R&B allows the darkest mood).



πŸ‘€ Author

Noam Fuchs β€” Data Science Assignment #1, March 2026

Downloads last month
218