Jack1808's picture
Upload README.md with huggingface_hub
848f77c verified
# ๐ŸŽง **Spotify Music Preference Analysis**
---
## ๐Ÿง  **Project Overview**
This project analyzes Spotify music data to predict song preferences using machine learning models. The analysis is based on a dataset of **195 songs (100 liked, 95 disliked)** with various audio features extracted from **Spotify's API**.
---
## ๐Ÿ“‚ **Dataset Description**
### ๐Ÿ“ฅ **Data Collection Process**
**Liked Songs (100 tracks):**
- ๐ŸŽต Primarily French Rap
- ๐ŸŽธ Some American Rap, Rock, and Electronic music
- โœ… Represents personal music preferences
**Disliked Songs (95 tracks):**
- ๐Ÿค˜ 25 Metal songs (Cannibal Corpse)
- ๐ŸŽค 20 Rap songs (PNL - personally disliked)
- ๐ŸŽผ 25 Classical songs
- ๐Ÿ•บ 25 Disco songs
- ๐Ÿšซ Pop songs excluded due to neutral preference
---
### ๐Ÿ“Š **Dataset Structure**
The dataset contains **195 rows** and **14 columns** with the following features:
---
## ๐ŸŽผ **Audio Features Explanation**
### ๐Ÿ”‘ **Key Predictive Features**
- **๐ŸŽต Danceability (0.0-1.0)**
- Measures how suitable a track is for dancing
- Based on tempo, rhythm stability, beat strength, and regularity
- Higher values indicate more danceable tracks
- **โšก Energy (0.0-1.0)**
- Represents intensity and activity level
- Energetic tracks feel fast, loud, and noisy
- Death metal = high energy, Bach prelude = low energy
- **๐Ÿ˜Š Valence (0.0-1.0)**
- Musical positiveness measure
- High valence = happy, cheerful, euphoric
- Low valence = sad, depressed, angry
- **๐ŸŽธ Acousticness (0.0-1.0)**
- Confidence measure of acoustic content
- 1.0 = high confidence the track is acoustic
- Important for distinguishing electronic vs. acoustic music
---
### ๐Ÿงฉ **Secondary Features**
- **๐Ÿ—ฃ๏ธ Speechiness (0.0-1.0)**
- Detects spoken words in tracks
- Above 0.66 = mostly speech (talk shows, audiobooks)
- 0.33-0.66 = mixed music and speech (rap music)
- Below 0.33 = mostly music
- **๐ŸŽผ Instrumentalness (0.0-1.0)**
- Predicts absence of vocals
- Values above 0.5 likely represent instrumental tracks
- โ€œOohโ€ and โ€œaahโ€ sounds treated as instrumental
- **๐Ÿ“ข Liveness (0.0-1.0)**
- Detects audience presence in recordings
- Above 0.8 = strong likelihood of live performance
- Useful for distinguishing studio vs. live recordings
- **๐Ÿ”Š Loudness (dB)**
- Overall track loudness in decibels
- Typically ranges from -60 to 0 dB
- Useful for comparing relative loudness between tracks
---
### โš™๏ธ **Technical Features**
- **๐Ÿฅ Tempo (BPM)**
- Estimated beats per minute
- Indicates the speed/pace of the music
- Directly derived from average beat duration
- **๐ŸŽน Key (0-11)**
- Musical key using Pitch Class notation
- 0 = C, 1 = Cโ™ฏ/Dโ™ญ, 2 = D, etc.
- Important for harmonic analysis
- **๐Ÿ”‘ Mode (0/1)**
- Musical modality
- 1 = Major scale, 0 = Minor scale
- Affects emotional perception of music
- **๐Ÿ“ Time Signature**
- Number of beats per bar/measure
- Common values: 3 (waltz), 4 (most popular music)
- **โฑ๏ธ Duration (ms)**
- Track length in milliseconds
- Useful for identifying song structure preferences
---
## ๐Ÿ“Š **Data Visualizations**
### 1๏ธโƒฃ **Box Plot Analysis**
- Compares each audio feature between liked (1) and disliked (0) songs
- Helps identify:
- ๐ŸŽฏ Feature distributions for each preference category
- โš ๏ธ Outliers in the data
- ๐Ÿšฆ Clear separations between liked and disliked songs
- ๐Ÿงช Discriminative features
![Boxplot](output[2].png)
---
### 2๏ธโƒฃ **Correlation Heatmap**
Reveals:
- ๐Ÿ” Relationships between audio features
- ๐Ÿงฌ Multicollinearity issues (highly correlated features)
- ๐Ÿ” Feature independence for model selection
- ๐Ÿ› ๏ธ Feature engineering opportunities
**Key insights:**
- Energy and loudness โ†’ strong positive correlation
- Acousticness and energy โ†’ negative correlation
- Valence โ†’ emotional interpretation link
![Boxplot](output[3].png)
---
### 3๏ธโƒฃ **Pair Plot Analysis**
- Shows relationships between: danceability, energy, valence, tempo, acousticness
- Detects:
- ๐ŸŽฏ Clustering patterns for liked vs. disliked
- ๐Ÿค Feature interactions
- ๐Ÿ“ˆ Distribution shapes
![Boxplot](output[4].png)
---
### 4๏ธโƒฃ **Model Performance Comparison**
Models Evaluated:
- โœ… Logistic Regression
- ๐ŸŒฒ Random Forest
- ๐Ÿง  Neural Network
- ๐Ÿ“ K-Nearest Neighbors (KNN)
- ๐Ÿ› ๏ธ Artificial Neural Network (ANN)
- ๐Ÿ“ Support Vector Machine (SVM)
- ๐Ÿ“Š Naive Bayes
- ๐Ÿš€ XGBoost
![Boxplot](output[1].png)
---
## ๐Ÿง  **Key Insights**
### โœ… Most Important Features:
- ๐Ÿ˜Š **Valence** โ€“ correlates with emotion
- โšก **Energy** โ€“ identifies genre intensity
- ๐Ÿ’ƒ **Danceability** โ€“ relates to rhythm preference
- ๐ŸŽธ **Acousticness** โ€“ distinguishes acoustic/electronic
- ๐Ÿ—ฃ๏ธ **Speechiness** โ€“ useful for rap detection
### โŒ Least Important Features:
- โฑ๏ธ Duration โ€“ length is less relevant
- ๐ŸŽน Key โ€“ minimal influence on likability
- ๐Ÿ“ Time Signature โ€“ usually standard
- ๐Ÿ“ข Liveness โ€“ studio vs. live not crucial
---
## ๐Ÿงช **Model Performance Insights**
- ๐ŸŒฒ **Ensemble methods** (Random Forest, XGBoost) perform best
- ๐Ÿง  **Neural Networks** capture complex patterns
- ๐Ÿงฎ **Simple models** like Logistic Regression provide baselines
- ๐Ÿ“Š Performance differences highlight feature complexity
---
## โš™๏ธ **Technical Implementation**
### ๐Ÿงผ Data Processing
- ๐ŸŽฏ **Feature Extraction** โ€“ Spotify API (audio features)
- ๐Ÿงน **Data Cleaning** โ€“ handle nulls/outliers
- ๐Ÿ“ **Feature Scaling** โ€“ normalize ranges
- ๐Ÿ”€ **Train-Test Split** โ€“ measure generalization
### ๐Ÿ“ Model Evaluation
- ๐ŸŽฏ **Accuracy** โ€“ main performance metric
- ๐Ÿ” **Cross-Validation** โ€“ stability check
- ๐Ÿ“Š **Feature Importance** โ€“ understand model decisions
- ๐Ÿงฉ **Confusion Matrix** โ€“ analyze misclassifications
---
## ๐Ÿ’ก **Applications**
- ๐ŸŽง Personal Music Recommendation Systems
- ๐ŸŽถ Understanding Music Preference Patterns
- ๐Ÿ“ Automated Playlist Generation
- ๐Ÿ“ˆ Music Streaming Service Improvements
- ๐Ÿ“Š Market Research for Music Industry
---
## ๐Ÿš€ **Future Enhancements**
- ๐Ÿ“ˆ **Larger Dataset** โ€“ more genre diversity
- ๐Ÿงฉ **Additional Features** โ€“ genre, artist, release year
- ๐Ÿค– **Advanced Models** โ€“ deep learning (e.g. RNN, CNN)
- ๐ŸŒ **Real-Time Prediction** โ€“ stream-integrated recommendations
- ๐Ÿง **Collaborative Filtering** โ€“ user-based recommendations
---
## ๐Ÿ“Ž **Dataset**
๐Ÿ“ File: [`data.csv`]
Content: Contains **195 rows** and **14 audio features** used for analysis and modeling.
---
> ๐Ÿง  This analysis demonstrates how machine learning can understand and predict personal music preferences using audio features extracted from Spotify's comprehensive music database.