Datasets:
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 fromtrack_album_release_date(covers 1957β2020)is_hitβTrueiftrack_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 readabilityduration_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 deriverelease_year. Once extracted, the original date string is redundant.playlist_subgenreβ all genre analysis operates at the broadplaylist_genrelevel. This column was never computed, visualized, or referenced.
Final dataset shape: (32,790, 25)
π Visualizations & Key Findings
1. Outlier Detection β All 10 Audio Features
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
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
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
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
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
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
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.
Clearly shows a difference in amount of data per each year.
9. 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
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









