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 |
|
| 48 |
-
|
| 49 |
|
| 50 |
-
|
| 51 |
-
|
|
|
|
|
|
|
| 52 |
|
|
|
|
| 53 |
|
| 54 |
-
|
| 55 |
|
| 56 |
-
|
|
|
|
|
|
|
|
|
|
| 57 |
|
| 58 |
-
|
|
|
|
|
|
|
|
|
|
| 59 |
|
| 60 |
-
|
| 61 |
-
|
| 62 |
-
|
| 63 |
-
|
| 64 |
-
|
| 65 |
-
| `energy` | float (0β1) | Intensity/activity level |
|
| 66 |
-
| `instrumentalness` | float (0β1) | Likelihood of no vocals |
|
| 67 |
-
| `key` | int (0β11) | Musical key (0 = C, 1 = C#/Db, etc.) |
|
| 68 |
-
| `liveness` | float (0β1) | Probability of live performance |
|
| 69 |
-
| `loudness` | float (dB) | Average loudness |
|
| 70 |
-
| `mode` | int (0/1) | 1 = major, 0 = minor |
|
| 71 |
-
| `speechiness` | float (0β1) | Presence of spoken words |
|
| 72 |
-
| `tempo` | float | Tempo in BPM |
|
| 73 |
-
| `time_signature` | int | Beats per measure |
|
| 74 |
-
| `valence` | float (0β1) | Musical positiveness |
|
| 75 |
|
| 76 |
-
|
| 77 |
|
| 78 |
-
|
|
|
|
|
|
|
|
|
|
| 79 |
|
| 80 |
-
|
| 81 |
-
| ------- | ---- | ----------------------- |
|
| 82 |
-
| `liked` | int | 1 = Liked, 0 = Disliked |
|
| 83 |
|
|
|
|
| 84 |
|
| 85 |
-
|
| 86 |
-
|
|
|
|
|
|
|
| 87 |
|
|
|
|
|
|
|
|
|
|
|
|
|
| 88 |
|
| 89 |
-
|
|
|
|
|
|
|
| 90 |
|
| 91 |
-
|
|
|
|
| 92 |
|
| 93 |
-
|
|
|
|
|
|
|
| 94 |
|
|
|
|
| 95 |
```bash
|
| 96 |
-
|
| 97 |
```
|
| 98 |
|
| 99 |
-
|
| 100 |
|
| 101 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 102 |
|
| 103 |
-
|
| 104 |
|
| 105 |
-
|
|
|
|
|
|
|
|
|
|
| 106 |
|
| 107 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
| 108 |
|
| 109 |
-
##
|
| 110 |
|
| 111 |
-
|
| 112 |
-
|
| 113 |
-
|
|
|
|
|
|
|
| 114 |
|
| 115 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
| 116 |
|
| 117 |
-
Feel free to fork, modify, or contribute to this music recommendation project!
|
|
|
|
| 1 |
+
# π΅ Music Feature Dataset Analysis
|
| 2 |
+
|
| 3 |
+
[](https://www.python.org/)
|
| 4 |
+
[](https://pandas.pydata.org/)
|
| 5 |
+
[](https://scikit-learn.org/)
|
| 6 |
+
[](LICENSE)
|
| 7 |
+
|
| 8 |
+
This repository contains a comprehensive exploratory data analysis (EDA) on a music features dataset. The primary objective is to understand the patterns in audio features and analyze how they relate to user preferences, providing insights for music recommendation systems and user profiling.
|
| 9 |
+
|
| 10 |
+
## π Table of Contents
|
| 11 |
+
- [Dataset Overview](#-dataset-overview)
|
| 12 |
+
- [Features Description](#-features-description)
|
| 13 |
+
- [Installation](#-installation)
|
| 14 |
+
- [Data Preprocessing](#-data-preprocessing)
|
| 15 |
+
- [Analysis & Visualizations](#-analysis--visualizations)
|
| 16 |
+
- [Key Findings](#-key-findings)
|
| 17 |
+
|
| 18 |
+
- [Usage](#-usage)
|
| 19 |
+
- [Results](#-results)
|
| 20 |
+
- [Technologies Used](#-technologies-used)
|
| 21 |
+
- [Contributing](#-contributing)
|
| 22 |
+
- [License](#-license)
|
| 23 |
+
|
| 24 |
+
## π Dataset Overview
|
| 25 |
+
|
| 26 |
+
The dataset (`train.csv`) contains audio features extracted from music tracks along with user preference scores. This rich collection of acoustic and musical attributes enables deep analysis of what makes music appealing to listeners.
|
| 27 |
+
|
| 28 |
+
**Dataset Statistics:**
|
| 29 |
+
- **Total Records:** [Insert actual count]
|
| 30 |
+
- **Features:** 13 audio features + 1 target variable
|
| 31 |
+
- **File Size:** [Insert size]
|
| 32 |
+
- **Format:** CSV
|
| 33 |
+
|
| 34 |
+
## πΌ Features Description
|
| 35 |
+
|
| 36 |
+
| Feature | Description | Data Type | Range/Values |
|
| 37 |
+
|---------|-------------|-----------|--------------|
|
| 38 |
+
| `danceability` | Measures how suitable a track is for dancing based on rhythm, tempo, and beat strength | Float | 0.0 - 1.0 |
|
| 39 |
+
| `energy` | Intensity and activity level representing loudness, dynamic range, and general entropy | Float | 0.0 - 1.0 |
|
| 40 |
+
| `key` | Musical key using standard Pitch Class notation | Integer | 0 - 11 |
|
| 41 |
+
| `loudness` | Overall loudness measured in decibels (dB) | Float | Typically -60 to 0 |
|
| 42 |
+
| `mode` | Modality of the track (Major = 1, Minor = 0) | Integer | 0, 1 |
|
| 43 |
+
| `speechiness` | Presence of spoken words in a track | Float | 0.0 - 1.0 |
|
| 44 |
+
| `acousticness` | Confidence measure of whether the track is acoustic | Float | 0.0 - 1.0 |
|
| 45 |
+
| `instrumentalness` | Predicts whether a track contains no vocals | Float | 0.0 - 1.0 |
|
| 46 |
+
| `liveness` | Detects the presence of an audience in the recording | Float | 0.0 - 1.0 |
|
| 47 |
+
| `valence` | Musical positiveness conveyed by a track | Float | 0.0 - 1.0 |
|
| 48 |
+
| `tempo` | Overall estimated tempo in beats per minute (BPM) | Float | Usually 50-200+ |
|
| 49 |
+
| `duration_ms` | Track duration in milliseconds | Integer | Positive integers |
|
| 50 |
+
| `time_signature` | Estimated overall time signature | Integer | 3, 4, 5, 7 |
|
| 51 |
+
| `liked` | **Target Variable:** User preference score | Float | Continuous values |
|
| 52 |
+
|
| 53 |
+
## π Installation
|
| 54 |
+
|
| 55 |
+
### Prerequisites
|
| 56 |
+
- Python 3.8 or higher
|
| 57 |
+
- pip package manager
|
| 58 |
+
|
| 59 |
+
### Setup Instructions
|
| 60 |
+
|
| 61 |
+
1. **Clone the repository:**
|
| 62 |
+
```bash
|
| 63 |
+
git clone https://github.com/yourusername/music-feature-analysis.git
|
| 64 |
+
cd music-feature-analysis
|
| 65 |
+
```
|
| 66 |
|
| 67 |
+
2. **Create virtual environment (recommended):**
|
| 68 |
+
```bash
|
| 69 |
+
python -m venv venv
|
| 70 |
+
source venv/bin/activate # On Windows: venv\Scripts\activate
|
| 71 |
+
```
|
| 72 |
|
| 73 |
+
3. **Install dependencies:**
|
| 74 |
+
```bash
|
| 75 |
+
pip install -r requirements.txt
|
| 76 |
+
```
|
| 77 |
|
| 78 |
+
### Required Libraries
|
| 79 |
+
```txt
|
| 80 |
+
pandas>=1.3.0
|
| 81 |
+
numpy>=1.21.0
|
| 82 |
+
matplotlib>=3.4.0
|
| 83 |
+
seaborn>=0.11.0
|
| 84 |
+
scikit-learn>=1.0.0
|
| 85 |
+
jupyter>=1.0.0
|
| 86 |
+
plotly>=5.0.0
|
| 87 |
+
```
|
| 88 |
|
| 89 |
+
## π§Ό Data Preprocessing
|
|
|
|
|
|
|
|
|
|
| 90 |
|
| 91 |
+
Our comprehensive preprocessing pipeline includes:
|
| 92 |
|
| 93 |
+
### 1. **Data Quality Assessment**
|
| 94 |
+
- β
Missing value detection and handling
|
| 95 |
+
- β
Duplicate record identification and removal
|
| 96 |
+
- β
Data type validation and conversion
|
| 97 |
+
- β
Outlier detection using statistical methods
|
| 98 |
|
| 99 |
+
### 2. **Feature Engineering**
|
| 100 |
+
- β
Z-score normalization for continuous variables
|
| 101 |
+
- β
Feature scaling and standardization
|
| 102 |
+
- β
Distribution analysis and transformation
|
| 103 |
+
- β
Correlation analysis between features
|
| 104 |
|
| 105 |
+
### 3. **Statistical Analysis**
|
| 106 |
+
- β
Descriptive statistics computation
|
| 107 |
+
- β
Distribution testing (normality, skewness)
|
| 108 |
+
- β
Variance analysis across features
|
| 109 |
+
- β
Feature importance assessment
|
| 110 |
|
| 111 |
+
## π Analysis & Visualizations
|
| 112 |
|
| 113 |
+
### Generated Visualizations
|
| 114 |
|
| 115 |
+
| Visualization | Purpose | Filename |
|
| 116 |
+
|---------------|---------|----------|
|
| 117 |
+
| Missing Values Heatmap | Data quality assessment | `missing_values_graph.png` |
|
| 118 |
+
| Unique vs Duplicated Records | Data integrity check | `unique_duplicated.png` |
|
| 119 |
+
| Z-Score Normalization | Feature scaling validation | `zscore.png` |
|
| 120 |
+
| Top/Bottom Liked Songs | Target variable distribution | `top_bottom_liked.png` |
|
| 121 |
+
| Feature Distributions | Understanding data patterns | `distribution.png` |
|
| 122 |
+
| Danceability Histogram | Specific feature analysis | `danceability_histogram.png` |
|
| 123 |
+
| Statistical Summary | Central tendency measures | `mean_std_plot.png` |
|
| 124 |
+
| Correlation Heatmap | Feature relationships | `correlation_heatmap.png` |
|
| 125 |
+
| Outlier Detection | Data quality insights | `boxplot.png` |
|
| 126 |
|
| 127 |
+
### Key Analytical Approaches
|
| 128 |
|
| 129 |
+
1. **Univariate Analysis:** Individual feature distributions and statistics
|
| 130 |
+
2. **Bivariate Analysis:** Pairwise relationships and correlations
|
| 131 |
+
3. **Multivariate Analysis:** Complex feature interactions
|
| 132 |
+
4. **Outlier Analysis:** Identification of anomalous data points
|
| 133 |
|
| 134 |
+
## π Key Findings
|
| 135 |
|
| 136 |
+
### π― **Primary Insights**
|
| 137 |
|
| 138 |
+
1. **Feature Distributions**
|
| 139 |
+
- Most audio features follow approximately normal distributions
|
| 140 |
+
- `valence` and `danceability` show interesting bimodal patterns
|
| 141 |
+
- `tempo` exhibits a wide range with multiple peaks
|
| 142 |
|
| 143 |
+
2. **Correlation Patterns**
|
| 144 |
+
- **Strong positive correlation** between `energy`, `valence`, and user preference (`liked`)
|
| 145 |
+
- **Moderate correlation** between `danceability` and `liked` scores
|
| 146 |
+
- **Weak correlation** for categorical features like `key` and `mode`
|
| 147 |
|
| 148 |
+
3. **User Preference Drivers**
|
| 149 |
+
- Higher `danceability` β Higher user preference
|
| 150 |
+
- Higher `valence` (positivity) β Better ratings
|
| 151 |
+
- Optimal `energy` levels correlate with user satisfaction
|
| 152 |
+
- `acousticness` shows inverse relationship with preferences
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 153 |
|
| 154 |
+
### π **Statistical Highlights**
|
| 155 |
|
| 156 |
+
- **Average liked score:** [Insert value]
|
| 157 |
+
- **Most influential feature:** Energy/Valence
|
| 158 |
+
- **Least predictive feature:** Key/Mode
|
| 159 |
+
- **Data quality:** [X]% complete records after preprocessing
|
| 160 |
|
| 161 |
+
## π Usage
|
|
|
|
|
|
|
| 162 |
|
| 163 |
+
### Quick Start
|
| 164 |
|
| 165 |
+
1. **Load and explore the data:**
|
| 166 |
+
```python
|
| 167 |
+
import pandas as pd
|
| 168 |
+
from src.data_preprocessing import load_and_clean_data
|
| 169 |
|
| 170 |
+
# Load the dataset
|
| 171 |
+
df = load_and_clean_data('data.csv')
|
| 172 |
+
print(df.info())
|
| 173 |
+
```
|
| 174 |
|
| 175 |
+
2. **Generate visualizations:**
|
| 176 |
+
```python
|
| 177 |
+
from src.visualization import create_correlation_heatmap, plot_distributions
|
| 178 |
|
| 179 |
+
# Create correlation heatmap
|
| 180 |
+
create_correlation_heatmap(df)
|
| 181 |
|
| 182 |
+
# Plot feature distributions
|
| 183 |
+
plot_distributions(df)
|
| 184 |
+
```
|
| 185 |
|
| 186 |
+
3. **Run complete analysis:**
|
| 187 |
```bash
|
| 188 |
+
python src/analysis.py
|
| 189 |
```
|
| 190 |
|
| 191 |
+
### Jupyter Notebook Workflow
|
| 192 |
|
| 193 |
+
```bash
|
| 194 |
+
# Start Jupyter Lab
|
| 195 |
+
jupyter lab
|
| 196 |
+
|
| 197 |
+
# Open notebooks in order:
|
| 198 |
+
# 1. notebooks/01_data_exploration.ipynb
|
| 199 |
+
# 2. notebooks/02_preprocessing.ipynb
|
| 200 |
+
# 3. notebooks/03_analysis.ipynb
|
| 201 |
+
```
|
| 202 |
|
| 203 |
+
## π Results
|
| 204 |
|
| 205 |
+
### Model Performance Insights
|
| 206 |
+
- Features most predictive of user preference: `energy`, `valence`, `danceability`
|
| 207 |
+
- Optimal feature ranges for high user satisfaction identified
|
| 208 |
+
- Recommendations for music recommendation system development
|
| 209 |
|
| 210 |
+
### Business Applications
|
| 211 |
+
1. **Music Recommendation Systems:** Use correlation insights for better suggestions
|
| 212 |
+
2. **Playlist Generation:** Apply valence and energy patterns for mood-based playlists
|
| 213 |
+
3. **A/B Testing:** Test hypothesis about feature importance in user engagement
|
| 214 |
+
4. **Content Curation:** Focus on high-correlation features for content selection
|
| 215 |
|
| 216 |
+
## π Technologies Used
|
| 217 |
|
| 218 |
+
### Core Libraries
|
| 219 |
+
- **Data Manipulation:** `pandas`, `numpy`
|
| 220 |
+
- **Visualization:** `matplotlib`, `seaborn`, `plotly`
|
| 221 |
+
- **Statistical Analysis:** `scipy`, `statsmodels`
|
| 222 |
+
- **Machine Learning:** `scikit-learn`
|
| 223 |
|
| 224 |
+
### Development Tools
|
| 225 |
+
- **Environment:** Jupyter Lab/Notebook
|
| 226 |
+
- **Version Control:** Git
|
| 227 |
+
- **Package Management:** pip/conda
|
| 228 |
+
- **Documentation:** Markdown
|
| 229 |
|
|
|