{"id":51974274,"url":"https://github.com/emp0ry/spotify-music-popularity-analysis","last_synced_at":"2026-07-30T03:01:27.848Z","repository":{"id":353755344,"uuid":"1111215108","full_name":"emp0ry/Spotify-Music-Popularity-Analysis","owner":"emp0ry","description":"Final project for the Spotify Music Data Analysis assignment","archived":false,"fork":false,"pushed_at":"2026-04-25T10:32:00.000Z","size":8994,"stargazers_count":3,"open_issues_count":0,"forks_count":0,"subscribers_count":0,"default_branch":"main","last_synced_at":"2026-04-25T12:22:29.494Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"Jupyter Notebook","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/emp0ry.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null,"notice":null,"maintainers":null,"copyright":null,"agents":null,"dco":null,"cla":null}},"created_at":"2025-12-06T13:58:52.000Z","updated_at":"2026-04-25T10:32:05.000Z","dependencies_parsed_at":null,"dependency_job_id":null,"html_url":"https://github.com/emp0ry/Spotify-Music-Popularity-Analysis","commit_stats":null,"previous_names":["emp0ry/spotify-music-popularity-analysis"],"tags_count":null,"template":false,"template_full_name":null,"purl":"pkg:github/emp0ry/Spotify-Music-Popularity-Analysis","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/emp0ry%2FSpotify-Music-Popularity-Analysis","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/emp0ry%2FSpotify-Music-Popularity-Analysis/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/emp0ry%2FSpotify-Music-Popularity-Analysis/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/emp0ry%2FSpotify-Music-Popularity-Analysis/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/emp0ry","download_url":"https://codeload.github.com/emp0ry/Spotify-Music-Popularity-Analysis/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/emp0ry%2FSpotify-Music-Popularity-Analysis/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":36057645,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-07-20T02:08:10.276Z","status":"online","status_checked_at":"2026-07-30T02:00:05.956Z","response_time":106,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2026-07-30T03:01:26.436Z","updated_at":"2026-07-30T03:01:27.776Z","avatar_url":"https://github.com/emp0ry.png","language":"Jupyter Notebook","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Spotify Music Popularity Analysis 🎧\n\nThis repository contains the final project for the **Spotify Music Data Analysis** assignment.  \nThe project explores how audio features relate to a song’s popularity and builds machine learning models to predict whether a track is **“High”** or **“Low”** popularity.\n\nThe entire workflow (EDA → feature engineering → clustering → classification → evaluation) is implemented in a single Jupyter notebook:\n\n\u003e `Final_Project.ipynb`\n\n---\n\n## 🎯 Project Goal\n\nThe main goal of this project is to:\n\n\u003e **Understand which audio features drive track popularity and build models that can predict whether a song will be “High” or “Low” popularity.**\n\nMore specifically:\n\n- Explore the distribution and relationships of Spotify audio features.\n- Identify which features are most correlated with popularity.\n- Group songs into distinct **clusters** based on their sound profile.\n- Train and compare **classification models** to predict popularity labels.\n\n---\n\n## 📂 Dataset\n\nThe analysis is based on two CSV files derived from a Spotify tracks dataset:\n\n- `high_popularity_spotify_data.csv` – tracks labeled as **High** popularity  \n- `low_popularity_spotify_data.csv` – tracks labeled as **Low** popularity  \n\nIn the notebook, these are combined into a single DataFrame with a target column:\n\n- `popularity` ∈ {`\"High\"`, `\"Low\"`}\n\nSeveral identifier / URL columns that are not useful for modeling are dropped, such as:\n\n- `track_album_id`, `track_id`, `id`, `playlist_id`, `track_href`, `uri`, `analysis_url`\n\n---\n\n## 🧪 Methods \u0026 Workflow\n\nAll steps are implemented and documented inside `Final_Project.ipynb`.\n\n### 1. Exploratory Data Analysis (EDA)\n\n- Checked for:\n  - Missing values (NaNs)\n  - Duplicate rows\n  - Suspicious “non-NaN” placeholders (e.g. `\"?\"`, `\"N/A\"`, etc.)\n- Removed rows with missing values.\n- Computed **summary statistics** for all numerical features.\n- Calculated **skewness** and **kurtosis** to understand distribution shapes.\n- Plotted **histograms and KDEs** for numerical features to:\n  - See how features are distributed.\n  - Detect outliers and heavy tails.\n\n### 2. Feature Engineering \u0026 Transformations\n\nTo improve data quality and make features more suitable for modeling:\n\n- Applied **log transforms** (`log1p`) to reduce right skew:\n  - `acousticness → acousticness_log`\n  - `liveness → liveness_log`\n  - `speechiness → speechiness_log`\n- Applied **Yeo–Johnson transformation** to handle skewed variables that include negative values:\n  - `loudness → loudness_yj`\n  - `instrumentalness → instrumentalness_yj`\n- Engineered a better duration feature:\n  - Transformed `duration_ms` with `log1p`, then standardized it → `duration_scaled`\n  - Dropped the original `duration_ms` to avoid redundancy.\n- Standardized **energy**:\n  - `energy → energy_scaled`\n- Dropped the original untransformed columns once transformed versions were created.\n\n### 3. Unsupervised Learning – K-Means Clustering\n\nTo explore natural groupings of songs:\n\n- Selected features:\n  - `energy_scaled`\n  - `loudness_yj`\n- Used **StandardScaler** where needed and created `X_scaled`.\n- Used the **Elbow Method** to choose the number of clusters.\n- Applied **K-Means** with `k = 3` and assigned cluster labels to each song.\n- Visualized clusters in a 2D scatter plot (`energy_scaled` vs `loudness_yj`) with centroids.\n- Interpreted clusters approximately as:\n  - **Cluster 0** – low energy, low loudness (calmer, quieter songs)\n  - **Cluster 1** – high energy, high loudness (energetic, loud tracks, e.g. party/workout music)\n  - **Cluster 2** – moderate energy and loudness (mid-tempo songs)\n\n### 4. Supervised Learning – Popularity Classification\n\nThe target variable is the **popularity label**:\n\n- `popularity = \"High\"` or `\"Low\"`\n\nFor modeling, the most relevant (and transformed) features were selected:\n\n- `energy_scaled`\n- `danceability`\n- `loudness_yj`\n- `instrumentalness_yj`\n- `acousticness_log`\n\nThe data is split into **train/test** sets using stratified sampling:\n\n- `test_size = 0.2`\n- `random_state = 42`\n- `stratify = y` (to keep class balance)\n\nTwo classification models are trained and evaluated:\n\n1. **Logistic Regression**\n   - Baseline linear model.\n   - Trained with `max_iter=1000`.\n   - Evaluated with:\n     - Accuracy\n     - Precision (for `\"High\"` class)\n     - Recall (for `\"High\"` class)\n     - F1-score\n     - Confusion matrix\n     - Classification report\n\n2. **Random Forest Classifier**\n   - Non-linear ensemble model.\n   - Configuration (from the notebook):\n     - `n_estimators = 300`\n     - `random_state = 42`\n     - `min_samples_split = 2`\n   - Evaluated with the same metrics as Logistic Regression.\n   - Feature importances extracted to understand which inputs drive predictions.\n\n**Model comparison (summary):**\n\n- The **Random Forest** model achieves better performance than Logistic Regression on the test set (higher F1-score and better classification report for the `\"High\"` class), making it the preferred model for this task.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Femp0ry%2Fspotify-music-popularity-analysis","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Femp0ry%2Fspotify-music-popularity-analysis","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Femp0ry%2Fspotify-music-popularity-analysis/lists"}