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.
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:
- Loads and preprocesses data
- Splits into training, validation, and test sets
- Trains multiple regression models
- Optimizes ensemble weights and hyperparameters using AOA
- Evaluates models using multiple metrics (R², RMSE, MAE, MSE)
- Produces visual outputs and exports all results
The provided example uses river discharge data, but users can replace it with any numerical dataset.
To use your own data:
- Place your file in the
./data/directory. - Update the filename and sheet names in
config/setting.yaml. - Run the main script again.
All parameters can be controlled from the configuration file.
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 Summary:
- Data Loading & Normalization using MinMaxScaler
- Base Regressors: Gradient Boosting, SVR, KNN
- Ensemble: Voting Regressor
- Optimization: AOA for weight and hyperparameter tuning
- Evaluation: Compute R², RMSE, MAE, MSE
- Visualization: Scatter plots, violin plots, and time-series comparisons
| 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 | ![]() |
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.
git clone https://github.com/rasoulameri/River_Discharge_Regression.git
cd River_Discharge_Regression
pip install -r requirements.txtTo run the framework:
python main.pyor for Jupyter visualization:
jupyter notebook notebooks/EDA_and_Visualization.ipynb| 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 |
The raw data used in this project (river discharge samples) are provided for demonstration. Users are encouraged to replace them with their own datasets.
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
Rasoul Ameri
📧 rasoulameri90@gmail.com
🔗 GitHub Profile



