{"id":31649328,"url":"https://github.com/nadirrezaou/demand-forecasting-with-random-forest","last_synced_at":"2026-05-04T08:43:09.273Z","repository":{"id":310474864,"uuid":"1039994914","full_name":"nadirrezaou/Demand-Forecasting-with-Random-Forest","owner":"nadirrezaou","description":"Forecasting product demand using Random Forest and sales data preprocessing.","archived":false,"fork":false,"pushed_at":"2025-08-18T10:18:19.000Z","size":2040,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":0,"default_branch":"main","last_synced_at":"2025-08-18T11:37:47.551Z","etag":null,"topics":["data-science","demand-forecasting","machine-learning","python","random-forest","regression","sales-prediction","sklearn"],"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/nadirrezaou.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-08-18T09:50:44.000Z","updated_at":"2025-08-18T10:18:23.000Z","dependencies_parsed_at":"2025-08-18T11:37:52.161Z","dependency_job_id":"f178fd64-67fe-4856-af81-45a13724a921","html_url":"https://github.com/nadirrezaou/Demand-Forecasting-with-Random-Forest","commit_stats":null,"previous_names":["nadirrezaou/demand-forecasting-with-random-forest"],"tags_count":null,"template":false,"template_full_name":null,"purl":"pkg:github/nadirrezaou/Demand-Forecasting-with-Random-Forest","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/nadirrezaou%2FDemand-Forecasting-with-Random-Forest","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/nadirrezaou%2FDemand-Forecasting-with-Random-Forest/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/nadirrezaou%2FDemand-Forecasting-with-Random-Forest/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/nadirrezaou%2FDemand-Forecasting-with-Random-Forest/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/nadirrezaou","download_url":"https://codeload.github.com/nadirrezaou/Demand-Forecasting-with-Random-Forest/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/nadirrezaou%2FDemand-Forecasting-with-Random-Forest/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":278740831,"owners_count":26037480,"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","status":"online","status_checked_at":"2025-10-07T02:00:06.786Z","response_time":59,"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":["data-science","demand-forecasting","machine-learning","python","random-forest","regression","sales-prediction","sklearn"],"created_at":"2025-10-07T07:42:16.408Z","updated_at":"2025-10-07T07:42:22.227Z","avatar_url":"https://github.com/nadirrezaou.png","language":"Jupyter Notebook","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Demand Forecasting with Random Forest\n\nDemand forecasting is the process of estimating **future customer demand** over a specific period by analyzing historical sales data and related features.  \n\nTraditionally, organizations use statistical forecasting methods such as **ARIMA, SARIMA, and Moving Averages**.  \nHowever, these methods often require significant domain expertise and manual tuning.  \n\nWith the rise of **Machine Learning**, new approaches have emerged that can automatically learn patterns from data and provide more accurate forecasts.  \n\n---\n\n## Table of Contents  \n\n- [Goal](#goal)  \n- [Data](#data)  \n- [Workflow](#workflow)  \n- [Result](#result)  \n- [Required Packages](#required-packages)  \n\n---\n\n## Goal  \n\nThe goal of this project is to explore the use of **machine learning models**, specifically the **Random Forest Regressor**, for predicting product demand.  \n\nUnlike traditional approaches, machine learning models can:  \n- Handle **large datasets**  \n- Capture **complex relationships**  \n- Process **categorical features** with minimal manual intervention  \n\nBy building and tuning a Random Forest model, we aim to improve the accuracy of demand forecasts and reduce prediction errors.  \n\n---\n\n## Data  \n\nThe dataset consists of daily sales records with the following fields:  \n\n- `record_ID` – Unique record identifier  \n- `week` – Date  \n- `store_id` – Store identifier  \n- `sku_id` – Product identifier  \n- `total_price` – Final price after discounts  \n- `base_price` – Original price  \n- `is_featured_sku` – Whether the product was featured  \n- `is_display_sku` – Whether the product was displayed  \n- `units_sold` – **Target variable** (number of units sold)  \n\n---\n\n## Workflow  \n\n### Data Preprocessing  \n- Split `week` column into `day`, `month`, `year`  \n- Handle missing values  \n- Remove outliers (top 1% sales)  \n- Drop irrelevant features (`record_ID`)  \n\n### Feature Engineering  \n- One-hot encode categorical variables (`store_id`, `sku_id`)  \n\n### Regression Modeling  \n- Split dataset into training and testing sets \n- Train a **Random Forest Regressor**  \n- Evaluate performance with **R² score** and **RMSE**  \n\n### Hyperparameter Tuning  \n- Use **GridSearchCV** to optimize parameters:  \n  - `n_estimators` (number of trees)  \n  - `min_samples_split` (minimum samples per split)  \n\n### Visualization  \n- Plot **predicted vs actual sales**  \n- Explore feature distributions and sales patterns  \n\n---\n\n## Result  \n\n- The model successfully predicts demand with a reasonable **R² score** and reduced **RMSE** compared to baseline.  \n- After **hyperparameter tuning**, the model achieves even better accuracy.  \n- Future improvements may include advanced models such as **XGBoost** or **Neural Networks**.  \n\n---\n\n## Required Packages  \n\n```txt\nnumpy\npandas\nscikit-learn\nmatplotlib\n\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fnadirrezaou%2Fdemand-forecasting-with-random-forest","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fnadirrezaou%2Fdemand-forecasting-with-random-forest","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fnadirrezaou%2Fdemand-forecasting-with-random-forest/lists"}