
- Jupyter Notebook100%
The project blends music and data science, offering an engaging way to apply machine learning in a real-world context. Itβs perfect for data enthusiasts who want to work with tangible and relatable data while also exploring how algorithms interpret patterns in music. Using Python Pandas, NumPy, Matplotlib, Seaborn ,Scikit-learn in Jupyter Notebook

A data-science notebook that explores audio features of Spotify tracks and groups songs using machine-learning techniques.
From README.md in the repository.
An Unsupervised Machine Learning project that clusters songs based on audio features and builds a recommendation engine.
This project analyzes a dataset of Spotify tracks to identify distinct clusters of songs based on their audio characteristics (e.g., danceability, energy, acousticness).
By applying Principal Component Analysis (PCA) for dimensionality reduction and K-Means Clustering, we segment songs into groups. These clusters are then used to power a Content-Based Recommendation System that suggests songs mathematically similar to a user's input.
| π Exploratory Analysis | π€ Machine Learning | π΅ Recommendation |
|---|---|---|
| Correlation Heatmaps: Identify relationships between audio features. |
PCA: Reduces high-dimensional data for visualization. |
Cluster Matching: Finds songs within the same geometric cluster. |
| Distribution Plots: Analyze the spread of genres and audio attributes. |
K-Means: Segments songs into 5 distinct genre/style clusters. |
Similarity Check: Filters recommendations based on feature proximity. |
The project follows a standard Data Science pipeline:
track_id, track_uri, etc.).StandardScaler to normalize features (Mean=0, Std=1) so that high-magnitude features (like Loudness) don't dominate the distance calculations.k=5).flowchart LR
subgraph Input
A[Raw Dataset] --> B(Data Cleaning)
end
subgraph Feature Engineering
B --> C[Feature Selection]
C -->|Danceability, Energy, etc.| D[StandardScaler]
end
subgraph Modeling
D --> E[PCA Reduction]
D --> F[K-Means Clustering]
E --> G[2D Visualization]
F --> H[Cluster Labels]
end
subgraph Output
H --> I{Recommendation Engine}
I -->|Input Song| J[Output Top 5 Similar Songs]
end
Project Structure Plaintext
βββ spotify_analysis.ipynb # Main Jupyter Notebook (or .py script) containing all logic
βββ spotify dataset.csv # Source data (ensure this is in root)
βββ requirements.txt # Python dependencies
βββ README.md # Project documentation
Installation & Usage
Bash python spotify_analysis.py 4. Get Recommendations To use the recommendation function inside the script/notebook:
Python
rec = recommend_songs('Shape of You', df_final) print(rec) π Visualizations The script generates several key insights:
Feature Distributions: Histograms showing the spread of Audio Features.
Correlation Matrix: A heatmap displaying how features like Energy and Loudness are positively correlated, while Acousticness and Energy are negatively correlated.
PCA Cluster Plot: A scatter plot visualizing how the K-Means algorithm has grouped the songs in 2D space.
Built with β€οΈ using Python, Scikit-Learn, and Pandas
GitHub data synced 25 Oct 2026