An open API service indexing awesome lists of open source software.

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.

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)

---