{"id":28798388,"url":"https://github.com/ilijamihajlovic/random-forest-classification","last_synced_at":"2026-05-08T15:42:30.594Z","repository":{"id":298525807,"uuid":"1000222714","full_name":"IlijaMihajlovic/Random-Forest-Classification","owner":"IlijaMihajlovic","description":"This project demonstrates how to build a Random Forest Classifier to predict music genres using audio feature data from Spotify. The model is trained on a curated subset of the spotify_tracks.csv dataset, focusing on popular genres such as pop, country, hip-hop, rock, latin, edm and more.","archived":false,"fork":false,"pushed_at":"2025-06-11T14:33:19.000Z","size":8349,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":0,"default_branch":"main","last_synced_at":"2025-06-11T16:08:28.672Z","etag":null,"topics":["ai","artificial-intelligence","machine-learning","machine-learning-algorithms","machinelearning","pandas","python","random-forest","random-forest-classifier","sckiit-learn","sckit-learn"],"latest_commit_sha":null,"homepage":"","language":"Jupyter Notebook","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/IlijaMihajlovic.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"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}},"created_at":"2025-06-11T12:57:33.000Z","updated_at":"2025-06-11T14:35:08.000Z","dependencies_parsed_at":"2025-06-11T16:19:28.690Z","dependency_job_id":null,"html_url":"https://github.com/IlijaMihajlovic/Random-Forest-Classification","commit_stats":null,"previous_names":["ilijamihajlovic/random-forest-classification"],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/IlijaMihajlovic/Random-Forest-Classification","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/IlijaMihajlovic%2FRandom-Forest-Classification","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/IlijaMihajlovic%2FRandom-Forest-Classification/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/IlijaMihajlovic%2FRandom-Forest-Classification/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/IlijaMihajlovic%2FRandom-Forest-Classification/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/IlijaMihajlovic","download_url":"https://codeload.github.com/IlijaMihajlovic/Random-Forest-Classification/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/IlijaMihajlovic%2FRandom-Forest-Classification/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":260491174,"owners_count":23017187,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","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":["ai","artificial-intelligence","machine-learning","machine-learning-algorithms","machinelearning","pandas","python","random-forest","random-forest-classifier","sckiit-learn","sckit-learn"],"created_at":"2025-06-18T05:06:50.453Z","updated_at":"2026-05-08T15:42:30.587Z","avatar_url":"https://github.com/IlijaMihajlovic.png","language":"Jupyter Notebook","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Random Forest Classification\n![Python](https://img.shields.io/badge/Python-3.7%2B-blue)\n![pandas](https://img.shields.io/badge/pandas-2.2%2B-orange)\n![scikit-learn](https://img.shields.io/badge/scikit--learn-1.6%2B-yellowgreen)\n![license](https://img.shields.io/badge/license-MIT-lightgrey.svg)\n![Status](https://img.shields.io/badge/status-active-brightgreen)\n![Jupyter](https://img.shields.io/badge/Jupyter-Notebook-orange)\n\nThis Jupyter notebook demonstrates how to build a Random Forest classifier to predict music genres from Spotify track audio features. The project uses data from `spotify_tracks.csv` to classify tracks into six genres.\n___\n\n## Key Features\n- **Data Preparation**: Loads and preprocesses Spotify track data, focusing on audio features\n- **Feature Engineering**: Selects relevant audio features and handles missing values\n- **Data Scaling**: Uses StandardScaler to normalize features for better model performance\n- **Random Forest Model**: Implements a Random Forest classifier with hyperparameter tuning\n- **Model Evaluation**: Includes confusion matrix, classification report, and accuracy metrics\n- **Feature Importance**: Visualizes which audio features most influence genre classification\n___\n\n## Requirements\n- Python\n- pandas\n- numpy\n- matplotlib\n- seaborn\n- scikit-learn\n- Jupyter Notebook\n___\n\n## Installing Python dependencies\n\nI recommend using **Python 3.7 or higher** for this project. If you do not have Python installed in your local environment, please visit [python.org](https://www.python.org/downloads/) for the latest download instruction. \n\nVerify installation with: `python --version`\n\nWith Python installed, please go to the Command Line interface of your operating system and use the `pip install` prompts below to install Pandas, NumPy, Matplotlib, Seaborn and scikit-learn respectively. \n\n### Package Installation\nRun these commands in your terminal/command prompt:\n\n```bash\npip install pandas numpy matplotlib seaborn scikit-learn\n```\n___\n\n## Jupyter Notebook (Optional)\n\nThe project is provided as a Jupyter Notebook (`.ipynb` file). You have two options:\n\n### 1. Install Jupyter (recommended for full interactivity):\n\n```bash\npip install jupyter\n```\n\n### 2. View without installation:\n- Use Google Colab\n___\n\n## Popularity Distribution\n*Distribution of track popularity across different music genres.*\n- Scale: Popularity scores (unlabeled range) are grouped by genre, with counts on the y-axis.\n- Trend: Pop and hip-hop dominate higher popularity counts, while country and EDM show narrower distributions.\n- Insight: The plot suggests genre plays a significant role in track popularity, with pop consistently leading.\n- Limitation: Exact popularity values are not specified, requiring further analysis for precise comparisons.\n\n  ![alt text](Images/Popularity_distribution_by_genre.png)\n\n\n## Danceability Distribution\n*Danceability Distribution by Genre.*\n- Scale: Danceability scores range from 0.2 to 1.0, with counts displayed on the y-axis.\n- Trend: EDM and pop tracks exhibit higher danceability, while country and hip-hop show broader variability.\n- Alignment: Genres like Latin and hip-hop cluster around mid-range scores, reflecting genre-specific rhythmic patterns.\n- Outliers: Some pop and EDM tracks reach near-maximum danceability, emphasizing their upbeat nature.\n\n  ![alt text](Images/Dancebility_distribution_by_genre.png)\n\n\n## Random Forest Feature Importance in Music Tracks\n*Random Forest analysis of key features influencing music tracks.*\n- Scale: The x-axis ranges from 0.00 to 0.12, representing the importance score of each feature.\n- Key Features: Popularity, speechiness, and danceability are the most influential factors, while mode and explicit have minimal impact.\n- Insight: The model highlights audio attributes like energy and acousticness as moderately important, suggesting they contribute to track performance.\n- Variability: Features like instrumentalness and liveness show lower importance, indicating their limited role in the model's predictions.\n\n  ![alt text](Images/Random_forest_importance_for_music_tracks.png)\n\n## License\n```\nMIT License\n\nCopyright (c) 2025 Ilija Mihajlovic\n\nPermission is hereby granted, free of charge, to any person obtaining a copy\nof this software and associated documentation files (the \"Software\"), to deal\nin the Software without restriction, including without limitation the rights\nto use, copy, modify, merge, publish, distribute, sublicense, and/or sell\ncopies of the Software, and to permit persons to whom the Software is\nfurnished to do so, subject to the following conditions:\n\nThe above copyright notice and this permission notice shall be included in all\ncopies or substantial portions of the Software.\n\nTHE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\nIMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\nFITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. IN NO EVENT SHALL THE\nAUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\nLIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\nOUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE\nSOFTWARE.\n\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Filijamihajlovic%2Frandom-forest-classification","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Filijamihajlovic%2Frandom-forest-classification","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Filijamihajlovic%2Frandom-forest-classification/lists"}