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.
![Energy Boxplot](boxplot_energy.png)

---

### 2. Boxplot: Danceability Distribution by Liked
This shows how danceability varies between liked and disliked songs.
![Danceability Boxplot](boxplot_danceability.png)

---

### 3. Scatter Plot: Energy vs Valence
This plot helps visualize clusters or spread of liked vs disliked songs based on energy and valence.
![Energy vs Valence](scatter_energy_valence.png)

---

### 4. Correlation Heatmap
This heatmap shows how all audio features correlate with each other.
![Correlation Heatmap](correlation.png)

### 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.

![Liked vs Disliked Countplot](countplot_liked.png)


## πŸ“‰ 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.

![Model Accuracy Chart](accuracy_comparison.png)