https://github.com/rasoulameri/river_discharge_regression
A hybrid machine learning framework for river discharge forecasting that combines ensemble regression models with the Arithmetic Optimization Algorithm (AOA) for hyperparameter tuning and next-day flow prediction.
https://github.com/rasoulameri/river_discharge_regression
correlation forecasting hybrid lag machine-learning mean-square-error optimization prediction regression regression-models river-discharge scatter-plot sklearn svm time-series time-series-analysis time-series-forecast time-series-forecasting time-series-prediction voting-regressor
Last synced: 4 months ago
JSON representation
A hybrid machine learning framework for river discharge forecasting that combines ensemble regression models with the Arithmetic Optimization Algorithm (AOA) for hyperparameter tuning and next-day flow prediction.
- Host: GitHub
- URL: https://github.com/rasoulameri/river_discharge_regression
- Owner: rasoulameri
- Created: 2025-10-07T11:02:38.000Z (4 months ago)
- Default Branch: main
- Last Pushed: 2025-10-07T11:13:59.000Z (4 months ago)
- Last Synced: 2025-10-07T13:19:31.284Z (4 months ago)
- Topics: correlation, forecasting, hybrid, lag, machine-learning, mean-square-error, optimization, prediction, regression, regression-models, river-discharge, scatter-plot, sklearn, svm, time-series, time-series-analysis, time-series-forecast, time-series-forecasting, time-series-prediction, voting-regressor
- Language: Python
- Homepage: https://www.linkedin.com/in/rasoulameri/
- Size: 4.1 MB
- Stars: 0
- Watchers: 0
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# π§ River Discharge Forecasting using Machine Learning and AOA Optimization
> **An intelligent framework for river discharge forecasting using ensemble regression models optimized by the Arithmetic Optimization Algorithm (AOA).**
> The dataset is prepared with **lag features** to forecast **next-day discharge**, but the framework can be easily adapted to other time series forecasting tasks.
---
## π§ Overview
This project integrates **machine learning regression models** (GBR, SVR, KNN, Voting Regressor)
with the **Arithmetic Optimization Algorithm (AOA)** to optimize model parameters and ensemble weights.
It is designed to predict **tomorrowβs river discharge** based on historical flow data, but users can replace the dataset to apply it to any regression or forecasting problem.
The framework automatically:
1. Loads and preprocesses data
2. Splits into training, validation, and test sets
3. Trains multiple regression models
4. Optimizes ensemble weights and hyperparameters using **AOA**
5. Evaluates models using multiple metrics (RΒ², RMSE, MAE, MSE)
6. Produces visual outputs and exports all results
---
## π Example Dataset
The provided example uses **river discharge data**, but users can replace it with any numerical dataset.
To use your own data:
1. Place your file in the `./data/` directory.
2. Update the filename and sheet names in `config/setting.yaml`.
3. Run the main script again.
---
## βοΈ Configuration (config/setting.yaml)
All parameters can be controlled from the configuration file.
```yaml
data:
name: "station1"
path: "./data/station1.xlsx"
sheet_range: [1, 5]
train:
split:
train_end: 2577
valid_end: 3105
batch_size: 32
epochs: 50
optimization:
method: "AOA"
population_size: 100
epochs: 100
alpha: 5
miu: 0.5
moa_min: 0.2
moa_max: 0.9
results:
metrics_dir: "./results/metrics/"
predictions_dir: "./results/predictions/"
plots_dir: "./results/prediction_plots/"
```
---
## π§© Workflow
**Workflow Summary:**
1. **Data Loading & Normalization** using MinMaxScaler
2. **Base Regressors:** Gradient Boosting, SVR, KNN
3. **Ensemble:** Voting Regressor
4. **Optimization:** AOA for weight and hyperparameter tuning
5. **Evaluation:** Compute RΒ², RMSE, MAE, MSE
6. **Visualization:** Scatter plots, violin plots, and time-series comparisons
---
## π Visual Outputs
| Type | Description | Example |
|------|-------------|---------|
| **Scatter Plots** | Predicted vs True values for all models |
|
| **Violin Plot** | Distribution of model predictions |
|
| **Time Series** | Comparison of predicted and true values over time |
|
---
## π§Ύ Results
All results (metrics, predictions, and visualizations) are automatically saved to:
```
results/
β
βββ metrics/ # RΒ², RMSE, MAE, MSE summary
βββ predictions/ # Excel files with model outputs
βββ prediction_plots/ # All generated plots
```
Each file is named according to the dataset and scenario defined in the configuration file.
---
## π¦ Installation
```bash
git clone https://github.com/rasoulameri/River_Discharge_Regression.git
cd River_Discharge_Regression
pip install -r requirements.txt
```
---
## βΆοΈ Usage
To run the framework:
```bash
python main.py
```
or for Jupyter visualization:
```bash
jupyter notebook notebooks/EDA_and_Visualization.ipynb
```
---
## π§ Example Models
| Model | Description |
|-------|-------------|
| **GBR** | Gradient Boosting Regressor |
| **SVR** | Support Vector Regressor |
| **KNN** | k-Nearest Neighbors Regressor |
| **VR** | Ensemble Voting Regressor |
| **AOA_VR** | AOA-tuned ensemble with optimal hyperparameters |
---
## π Data Availability Statement
The raw data used in this project (river discharge samples) are provided for demonstration. Users are encouraged to replace them with their own datasets.
---
## π Repository Structure
```
River_Discharge_Regression/
β
βββ config/
β βββ setting.yaml # Main configuration
β
βββ data/
β βββ River_Discharge.xlsx # Example dataset
β
βββ src/
β βββ models.py
β βββ data_loader.py
β βββ evaluate.py
β βββ optimization.py
β βββ train.py
β
βββ results/
β βββ metrics/
β βββ predictions/
β βββ prediction_plots/
β
βββ requirements.txt
β
ββ main.py
```
---
## π« Contact
**Rasoul Ameri**
π§ [rasoulameri90@gmail.com](mailto:rasoulameri90@gmail.com)
π [GitHub Profile](https://github.com/rasoulameri)
---