| # ๐ง **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 | |
|  | |
| --- | |
| ### 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 | |
|  | |
| --- | |
| ### 3๏ธโฃ **Pair Plot Analysis** | |
| - Shows relationships between: danceability, energy, valence, tempo, acousticness | |
| - Detects: | |
| - ๐ฏ Clustering patterns for liked vs. disliked | |
| - ๐ค Feature interactions | |
| - ๐ Distribution shapes | |
|  | |
| --- | |
| ### 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 | |
|  | |
| --- | |
| ## ๐ง **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. | |