File size: 6,027 Bytes
0110704 | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 |
# π΅ Spotify Song Preference Dataset
This dataset contains Spotify audio features for 195 songs categorized as **liked** or **disliked** by the user. It was created to build and train ML models that can predict user preferences in music based on quantitative audio features.
---
## π₯ Dataset Overview
- **Total songs**: 195
- **Format**: CSV (`data.csv`)
- **Source**: Spotify API
- **Target column**: `liked` (1 = liked, 0 = disliked)
- **Data type**: Tabular
- **Licensing**: For academic and personal research use (derived from Spotify API)
---
## π¦ Dataset Composition
| Category | Count | Description |
|--------------|-------|---------------------------------------------|
| Liked | 100 | Mostly French/American rap, rock, electro |
| Disliked | 95 | 25 metal, 25 classical, 25 disco, 20 rap |
| Neutral (Pop)| β Not included (user is neutral) |
---
## π§ͺ Features
Extracted via Spotify API β "Get Audio Features for Several Tracks"
| Feature | Description |
|-------------------|-----------------------------------------------------------------------------|
| `danceability` | How suitable the track is for dancing (0β1) |
| `energy` | Perceived intensity (0β1) |
| `key` | Musical key (0 = C, 1 = Cβ―/Dβ...) |
| `loudness` | Overall volume in dB (-60 to 0) |
| `mode` | 1 = major, 0 = minor |
| `speechiness` | Detects presence of speech (0β1) |
| `acousticness` | Confidence measure of being acoustic (0β1) |
| `instrumentalness` | Predicts presence of vocals (0β1) |
| `liveness` | Live audience presence (0β1) |
| `valence` | Positiveness of the song (0β1) |
| `tempo` | Beats per minute (BPM) |
| `duration_ms` | Duration of the song in milliseconds |
| `time_signature` | Estimated time signature (e.g. 4 = 4/4) |
| `liked` (target) | 1 = liked, 0 = disliked |
---
## π Exploratory Data Analysis (EDA)
### β
1. Missing Values
- No missing values found
### β
2. Class Distribution
- Liked (1): 100 songs
- Disliked (0): 95 songs
- **Class is balanced**
### β
3. Data Types
- All features are numerical
- Target (`liked`) is binary
### β
4. Summary Statistics
- Energy, Danceability, Valence tend to be higher for liked songs
- Acousticness and Instrumentalness higher in disliked songs
### β
5. Correlation Matrix
- Strong positive correlation: `energy` β `loudness`
- Negative correlation: `acousticness` β `energy`, `valence`
### β
6. Visual Highlights (Suggested)
- **Boxplots**: `energy`, `danceability` by `liked`
- **Countplot**: class balance of `liked`
- **Heatmap**: correlation of features
- **Scatter**: `energy` vs `valence` colored by `liked`
---
## π€ ML Use Cases
You can use this dataset to train:
- Logistic Regression
- Random Forest
- KNN / SVM
- ANN / XGBoost / LightGBM
- Naive Bayes
---
## π Visualizations
### 1. Boxplot: Energy Distribution by Liked
This shows how energy values are distributed for liked and disliked songs.

---
### 2. Boxplot: Danceability Distribution by Liked
This shows how danceability varies between liked and disliked songs.

---
### 3. Scatter Plot: Energy vs Valence
This plot helps visualize clusters or spread of liked vs disliked songs based on energy and valence.

---
### 4. Correlation Heatmap
This heatmap shows how all audio features correlate with each other.

### 5. Countplot: Liked vs Disliked Songs
This chart shows the number of songs in each class: `0 = Disliked`, `1 = Liked`.
It confirms that the dataset is nearly balanced.

## π Statistical Testing
To determine which features are statistically different between liked and disliked songs, a two-sample t-test was performed using:
| Feature | p-value | Significance |
| ---------------- | ------- | ----------------- |
| danceability | 0.0000 | β
Significant |
| energy | 0.0159 | β
Significant |
| key | 0.5371 | β Not significant |
| loudness | 0.0000 | β
Significant |
| mode | 0.7418 | β Not significant |
| speechiness | 0.0000 | β
Significant |
| acousticness | 0.0134 | β
Significant |
| instrumentalness | 0.0000 | β
Significant |
| liveness | 0.8924 | β Not significant |
| valence | 0.0002 | β
Significant |
| tempo | 0.0000 | β
Significant |
| duration_ms | 0.0000 | β
Significant |
| time_signature | 0.0023 | β
Significant |
π Observation:
- Features with p-value > 0.05 are statistically insignificant
- These features do not show a meaningful difference between liked and disliked songs
- We can safely remove the following features:
liveness
mode
key
β
This simplifies the dataset and improves model performance by removing noise.
## π Model Accuracy Comparison
Bar chart showing accuracy of different models used in the project.

|