My_Dataset / README.md
hardik-0212's picture
Update README.md
de567d8 verified
# 🎡 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)