Predicting missing historical or forecasting streamflows for future periods is a challenging task. This paper presents open-source data-driven machine learning models for streamflow prediction. The Random Forests algorithm is employed and the results are compared with other machine learning algorithms. The developed models are applied to the Kızılırmak River, Turkey. First model is built with streamflow of a single station (SS), and the second model is built with streamflows of multiple stations (MS). The SS model uses input parameters derived from one streamflow station. The MS model uses streamflow observations of nearby stations. Both models are tested to estimate missing historical and predict future streamflows. Model prediction performances are measured by root mean squared error (RMSE), Nash–Sutcliffe efficiency (NSE), coefficient of determination (R2), and percent bias (PBIAS). The SS model has an RMSE of 8.54, NSE and R2 of 0.98, and PBIAS of 0.7% for the historical period. The MS model has an RMSE of 17.65, NSE of 0.91, R2 of 0.93, and PBIAS of −13.64% for the future period. The SS model is useful to estimate missing historical streamflows, while the MS model provides better predictions for future periods, with its ability to better catch flow trends.

  • An open-source machine learning model to estimate streamflow.

  • Use of single- and multi-streamflow station datasets as inputs are compared.

  • A single streamflow station can be used to estimate its missing flows in a historical period.

  • A multi-station model can better capture streamflow trends.

ANNs

artificial neural networks

DL

deep learning

ELM

extreme learning machine

ML

machine learning

MS

multi-station

NSE

Nash–Sutcliffe Efficiency

RF

Random Forests

RMSE

root mean squared error

SS

single station

SVMs

support vector machines

SVR

support vector regression

SWAT

Soil and Water Assessment Tool

WNNs

wavelet neural networks

XGBoost

extreme gradient boosting

Streamflow is widely used in water resource planning and management, including hydropower planning and operations, water supply operations for urban, agriculture and environment, drought management, and flood mitigation. Accurate, timely and continuous streamflow predictions provide stakeholders and decision-makers with essential information (Besaw et al. 2010) for better managing complex water systems and efficient water resource management (Ghobadi & Kang 2022). Many parameters, such as precipitation, temperature, evapotranspiration, land use, topography and soil characteristics, affect and contribute to streamflow, characterized by a nonlinear relationship between streamflow and watershed characteristics (Adnan et al. 2019; Shah et al. 2021). Streamflow is often measured at stream gauge stations, calculated via physically-based hydrological models, or statistically estimated via data-driven empirical models. Although in situ observations are important for obtaining accurate streamflow records, spatiotemporal availability of stream gauge observations for desired locations can be limited. Moreover, these stations can wrongly measure streamflow due to human or instrument error, requiring re-evaluation, and estimation of flows for the missing periods. Hydrological models, based on explicit relationships between inputs and outputs, are data-intensive and require good system knowledge, involving physical formulas to describe the complicated meteorological and hydrological processes (Feng et al. 2022; Cacal et al. 2023). Without prior knowledge of hydrological systems, statistically-based or data-driven models, including machine learning, however, mathematically connect inputs and outputs and disregard intervening physical processes (Chu et al. 2021; Duarte et al. 2022). These empirical models are less data-intensive and can be easily applied, especially, when the objective is to estimate missing or falsely measured flows in a stream flow dataset or predict short-term future flows.

As more water-related data become available, the use of machine learning models to estimate historical or forecast future streamflows has gained popularity over the past two decades. These regression-based machine learning models find statistical relationships between input data and target for a past period, called training and make predictions for desired periods. Several machine learning algorithms have been used to predict streamflow. Govindaraju (2000), Sit et al. (2020) and Khullar & Singh (2021) reviewed early and recent machine learning applications in hydrology and water resources. Commonly used algorithms are artificial neural networks (ANNs), support vector machines (SVMs), Random Forests (RF), extreme gradient boosting (XGBoost), and deep learning (DL). Hsu et al. (1995) used the ANN to model the rainfall–runoff process. Besaw et al. (2010) used the ANN to forecast streamflow for ungauged basins. Erdal & Karakurt (2013) estimated monthly streamflow with RF and SVM and concluded that RF yields promising outputs. Booker & Woods (2014) compared RF hydrology estimates with a physically-based model and concluded that RF shows good performance at estimating hydrological parameters. Noori & Kalin (2016) predicted daily streamflow for ungauged watersheds with the ANN model coupled with Soil and Water Assessment Tool (SWAT), a physically-based hydrological model. Petty & Dhingra (2018) used RF to predict streamflow for flood forecasting. Adnan et al. (2019, 2020) predicted daily and monthly streamflow, respectively, with an optimally pruned extreme learning machine (ELM). Dalkiliç & Hashimi (2020) predicted daily streamflow using ANN, wavelet neural networks (WNNs), and adaptive neuro-fuzzy inference system and concluded that WNN provides more accurate estimates. Li et al. (2020) showed that RF presents better and more stable streamflow prediction performance than other machine learning algorithms, namely SVM and XGBoost. Ni et al. (2020) developed a model to predict monthly streamflow, coupling XGBoost with the Gaussian mixture model. Shijun et al. (2020) used an RF algorithm to forecast medium and long-term runoff. Kumar et al. (2021) used SVM to model real-time streamflow using satellite inputs. Lin et al. (2021) developed a hybrid DL model to predict hourly streamflow. Feng et al. (2022) used ELM based on a sparrow search algorithm for forecasting runoff time series. Ghobadi & Kang (2022) developed a DL model for predicting long-term streamflow on a monthly time scale. Xu et al. (2022) used the DL method to predict monthly streamflow, including variables from general circulation models. Sayed et al. (2023) simulated the rainfall–runoff process with two hydrological models and two ML models and concluded that ML models are effective forecasting tools.

RF is a decision tree-based classification and regression algorithm. RF grows several decision trees throughout the model-building process, trained by a bootstrapped sample of the input dataset (Panahi et al. 2022). For regression problems, such as streamflow prediction, the final output is an ensemble average of all individual tree decisions in the forest (Breiman 2001).

Selecting appropriate algorithms and input variables when predicting missing streamflows or forecasting future streamflows for data-driven models is important, yet little research has addressed it. In addition, most of the developed models are not transparent. The goal of this paper is to help researchers choose optimal input variables with minimum data requirements by comparing single and multi-station datasets and determine the best algorithm for streamflow prediction. Also, it is aimed to develop an open-source, flexible and easy-to-adapt model. All source code and data are shared online via GitHub (Dogan 2023). The model is built with Scikit-Learn, an open-source machine learning library in Python (Pedregosa et al. 2011). Daily streamflow prediction is employed for the Kızılırmak River, Turkey, but the developed model is independent of data resolution. Thus, depending on the data availability, other time steps, such as hourly, weekly or monthly, can be used.

Study area

The Kızılırmak River Basin is selected to demonstrate the developed model. Originating in the high plains of eastern Anatolia and flowing into the Black Sea, the Kızılırmak River is the longest in Turkey, with a total length of 1,355 km (Efe 1996). The river basin has a drainage area of 78,180 square kilometres and an annual average flow rate of 187 m3/s (Efe 1996). As shown in Figure 1, five streamflow stations are selected in the Kızılırmak River Basin to build a data-driven model. Station #1543 is the target station with assumed missing flows, and the remaining stations (#1539, #1535, #1501, and #1517) are named nearby stations in the basin. The streamflow dataset is obtained from DSI (2022).
Figure 1

Study area: Kızılırmak River Basin with selected streamflow stations.

Figure 1

Study area: Kızılırmak River Basin with selected streamflow stations.

Close modal
All five streamflow stations have daily average streamflows in cubic metres per second (), covering a period from October 1, 2010 to September 30, 2015, shown in Figure 2(a). Each daily streamflow value is assumed independent (Yang et al. 2016; Adnan et al. 2020). The streamflow dataset is separated into two groups: one from October 1, 2010 to September 30, 2014, and the other from October 1, 2014 to September 30, 2015. The former period is called the ‘historical period’ and the latter is called the ‘future period’ throughout the study (Figure 2(b)). The historical period is split into two groups: 75% of streamflows are used to train the model, and 25% of randomly selected streamflows, representing missing streamflows and the whole dataset in the future period is used to test the algorithm. 25% of historical streamflows and future period streamflow time series are unseen by the model. All predictions are from the same model trained by streamflows and associated variables from 75% of the historical period. The objective is to estimate arbitrarily selected 25% of missing streamflows of station #1543 in the historical period and predict a complete daily time series of station #1543 in the future period.
Figure 2

(a) Observed daily flow of all stations and (b) observed daily flow of station #1543. The calibration and validation or historical period are from October 1, 2010 to September 30, 2014. The future period is from October 1, 2014 to September 30, 2015.

Figure 2

(a) Observed daily flow of all stations and (b) observed daily flow of station #1543. The calibration and validation or historical period are from October 1, 2010 to September 30, 2014. The future period is from October 1, 2014 to September 30, 2015.

Close modal

RF model

Proposed by Breiman (2001), RF is a supervised machine learning algorithm and a robust ensemble method for regression analysis (Salmasi et al. 2021), without an issue of overfitting. Overfitting is a condition where the model performs well on training data but poorly on unseen test data (Yang et al. 2016). Unlike standard decision trees, in the RF algorithm, each node is split with the best among a subset of input variables randomly chosen at that node, instead of selecting all input sets (Liaw & Wiener 2002). RF has a good prediction performance and outperforms other commonly used machine learning algorithms, such as SVMs and neural networks (Yang et al. 2016). A comparison of RF to other ML algorithms is discussed later. The forest consists of randomly grown binary regression decision trees. A regression tree finds optimal splits in the list of input variables (Breiman et al. 1984; Schnier & Cai 2014). For an input variable space K, the optimal partitioning variable and optimal partitioning (split) point j that minimize squared error are selected at each node, which is expressed as follows:
(1)
where y is the actual or observed value and is the prediction. The final prediction of the model is the ensemble average of predictions from each regression decision tree in the forest.

Input variables of the single-station (SS) model and multi-station (MS) model are shown in Table 1, with data range, mean and standard deviation values for the training period from October 1, 2010 to September 30, 2014. For the SS model, variables are derived from a streamflow time-series dataset of station #1543. The training data are from October 1, 2010 to September 30, 2014 in a daily time-step. The derived parameters for the SS model are day of the month ; the month of the year ; year of the date ; maximum flow in a given month ; mean flow in a given month ; minimum flow in a given month ; maximum flow in a given year ; mean flow in a given year ; and minimum flow in a given year . For the MS model, daily streamflow datasets from four stations (#1539; #1535; #1517; and #1501) are usedfrom October 1, 2010 to September 30, 2014. All these stations are located in the Kızılırmak River Basin. Both SS and MS models are trained to predict the assumed missing streamflows (target variable) of station #1543.

Table 1

Input (independent) variables of training period (October 1, 2010–September 30, 2014) for single- and multi-station models

Single-station model variableData rangeMeanStandard deviation
 
[1, 31] – – 
 
[1, 12] – – 
 
[2010, 2014] – – 
 
[9, 546] 88 114 
 
[11, 178] 54 50 
 
[1, 149] 34 40 
 
[71, 546] 358 182 
 
[19, 70] 54 20 
 
[1, 10] 
Multi-station model variable Data range Mean Standard deviation 
  • #1539 Streamflow

 
[1, 131] 12 18 
  • #1535 Streamflow

 
[2, 301] 31 42 
  • #1517 Streamflow

 
[1, 25] 
  • #1501 Streamflow

 
[6, 111] 62 27 
Target variable Data range Mean Standard deviation 
  • , Streamflow at Station #1543

 
[1, 546] 54 68 
Single-station model variableData rangeMeanStandard deviation
 
[1, 31] – – 
 
[1, 12] – – 
 
[2010, 2014] – – 
 
[9, 546] 88 114 
 
[11, 178] 54 50 
 
[1, 149] 34 40 
 
[71, 546] 358 182 
 
[19, 70] 54 20 
 
[1, 10] 
Multi-station model variable Data range Mean Standard deviation 
  • #1539 Streamflow

 
[1, 131] 12 18 
  • #1535 Streamflow

 
[2, 301] 31 42 
  • #1517 Streamflow

 
[1, 25] 
  • #1501 Streamflow

 
[6, 111] 62 27 
Target variable Data range Mean Standard deviation 
  • , Streamflow at Station #1543

 
[1, 546] 54 68 

Target variable is station #1543 streamflow.

Machine learning algorithms, including RF, operate based on the trend and relationship between input variables and the output target variable. A strong correlation between inputs and the target yields better prediction performance.Figure 3(a)) shows cross-correlation of input () and target () variables for the SS model. Maximum (), mean (), and minimum () daily streamflows in a given month are strongly correlated with daily streamflow (), with correlation coefficients close to 1. The daily streamflow target variable () is obtained from station #1543. Figure 3(b)) shows cross-correlation of input (#1539, #1535, #1517, #1501) and target (#1543) variables for the MS model. Stations #1539 and #1535 streamflows are highly correlated with station #1543 streamflows. Station #1501 is located downstream large reservoir. Therefore, its observations are affected by reservoir releases. Less correlated variables, such as and in the SS model and station #1501 in the MS model, have little impact on the prediction performance as they are less important features.
Figure 3

Cross-correlation of input variables of (a) SS and (b) MS models. Station #1543 streamflows are used in the SS model (Q).

Figure 3

Cross-correlation of input variables of (a) SS and (b) MS models. Station #1543 streamflows are used in the SS model (Q).

Close modal
An example decision tree is illustrated in Figure 4. This tree, with a depth of 2, is built with two input variables: maximum flow and minimum flow in , in a given month. Split values are shown on the top of each node with an inequality sign. Input values are compared to the split thresholds at each node. If true, then the left side, if false, the right side of the tree branch is followed. The bottom layer is called leaves and represents the final decision value. There are four leaves in this decision tree. The following example shows how a regression decision tree works. Assume that prediction input variables values are . Split thresholds are compared to input variable values. Is false?. Is true?. Then output value or streamflow prediction is . In the RF algorithm, many randomly grown decision trees are built and the ensemble average of individual decisions is taken for the final output.
Figure 4

An example regression decision tree with a depth of 2 and two input variables ().

Figure 4

An example regression decision tree with a depth of 2 and two input variables ().

Close modal

Model parameter calibration

The number of trees in ensemble, maximum tree depth and the maximum number of features parameters are calibrated to optimize the prediction performance of the developed models. The number of trees in the ensemble determines how many trees to grow in the forest. Growing too many trees can increase computation time, while fewer trees can result in poor prediction performance. The depth and the number of features or input variables determine tree size. Increased depth and the number of features result in more tree branches, and thus larger trees with more leaves. However, as shown in Figure 5, after a certain point, increasing these parameters does not improve the model's prediction performance measured by the root mean squared error (RMSE) between predicted and observed values. Calibrated parameters for both SS and MS models are the number of trees in the ensemble is 40, the maximum tree depth is 10, and the maximum number of features is 8.
Figure 5

Model parameter calibration for (a) SS and (b) MS models. Calibrated parameter numbers are shown under blue bars. Please refer to the online version of this paper to see this figure in colour: http://dx.doi.org/10.2166/wst.2023.171.

Figure 5

Model parameter calibration for (a) SS and (b) MS models. Calibrated parameter numbers are shown under blue bars. Please refer to the online version of this paper to see this figure in colour: http://dx.doi.org/10.2166/wst.2023.171.

Close modal

Daily streamflows are predicted with SS and MS models and compared to observed streamflows. Missing streamflows in historical periods are predicted and future streamflows are forecasted using SS and MS models. Model prediction performances are presented. The RF algorithm is compared to other commonly used ML algorithms.

Historical period streamflow estimation

Figure 6 compares daily predicted streamflows to observed streamflows for (a) the SS model and (b) the MS model for the historical period. These values are randomly selected and withheld from the training dataset and correspond to 25% of the time series between October 1, 2010 and September 30, 2014. Both models have a good prediction performance. The SS model has fewer differences between predicted and observed streamflows and better aligns with the diagonal perfect fit line. The SS model slightly underpredicts streamflow, while the MS model predictions are slightly higher than observed streamflows.
Figure 6

Predicted and observed daily flow with (a) SS and (b) MS station data in the historical period (25% of October 1, 2010–September 30, 2014).

Figure 6

Predicted and observed daily flow with (a) SS and (b) MS station data in the historical period (25% of October 1, 2010–September 30, 2014).

Close modal

Future period streamflow forecast

Figure 7 shows future period daily streamflow predictions of SS and MS models. This period is from October 1, 2014 to September 30, 2015. Developed RF models are not trained with any streamflow values during this period. While both SS and MS models can follow the overall streamflow trend, the MS model can better capture flow peaks, illustrated in Figure 6(a). Except for a few peaks, the MS model slightly overpredicts in this period. Differences between predicted and observed streamflows are higher in the SS model (Figure 6(b)). Since taking the ensemble average reduces variance, the RF algorithm shows good performance on average flows rather than maximum and minimum flows. Therefore, the monthly average of daily predictions in both SS and MS models is closer to the monthly average observed streamflows.
Figure 7

2015 water year (October 1, 2014–September 30, 2015) SS and MS predictions with observed flows in the future period: (a) Daily and monthly flow time series and (b) daily and monthly average flow comparison.

Figure 7

2015 water year (October 1, 2014–September 30, 2015) SS and MS predictions with observed flows in the future period: (a) Daily and monthly flow time series and (b) daily and monthly average flow comparison.

Close modal

Prediction performances

The following indicators are used to measure the prediction performance of developed models using the RF algorithm: the RMSE, Nash–Sutcliffe efficiency (NSE), coefficient of determination (R2) and percent bias (PBIAS), shown in Equations (2)–(5), respectively. In these equations, is the daily streamflow prediction by SS or MS models, is the observed daily streamflow, is the mean daily predicted streamflow, is the mean daily observed streamflow, and n is the length of streamflow time series:
(2)
(3)
(4)
(5)

Prediction performances of SS and MS models are summarized in Table 2. Performance indicators of single- and multi-station models for the historical and future periods with performance indicators. Mean () and standard deviation () of daily observed streamflow of the training period are 54.80 and 69.79 , respectively, which are mean and standard deviation values of 75% of streamflow in the period from October 1, 2010 to September 30, 2014. For the historical period, the SS model has better prediction performance, where the mean predicted streamflow () is closer to the mean observed streamflow (). RMSE and PBIAS are smaller, while NSE and R2 are greater than the MS model in the historical period. For the future period, however, the MS model has better prediction performance in terms of RMSE, NSE and R2 indicators, even though the SS model's mean predicted streamflow () is closer to the mean observed streamflow (), compared to the mean predicted streamflow of the MS model (). Moreover, the MS model has a greater absolute PBIAS than the SS model. The MS model's predictions are slightly more biased and the model tends to overpredict, while the SS model has less PBIAS with a tendency to underpredict streamflows.

Table 2

Performance indicators of single- and multi-station models for the historical and future periods

ParameterSingle stationMulti-station
Historical period (October 1, 2010–September 30, 2014)   
  • μtrain, observed (75% of data, )

 
54.80 
  • σtrain, observed (75% of data, )

 
69.79 
  • μtest, observed (25% of data, )

 
51.28 
  • σtest, observed (25% of data,

 
63.83 
  • μpredicted ()

 
50.91 52.43 
  • σpredicted ()

 
61.83 66.55 
  • RMSE ()

 
8.54 15.51 
  • NSE

 
0.98 0.94 
  • R2

 
0.98 0.95 
  • PBIAS

 
0.70% −2.24% 
Future period (October 1, 2014–September 30, 2015)   
  • μobserved ()

 
56.32 
  • σobserved (

 
57.93 
  • μpredicted ()

 
54.63 64.0 
  • σpredicted (

 
47.59 58.76 
  • RMSE ()

 
24.71 17.65 
  • NSE

 
0.82 0.91 
  • R2

 
0.83 0.93 
  • PBIAS

 
3.01% −13.64% 
ParameterSingle stationMulti-station
Historical period (October 1, 2010–September 30, 2014)   
  • μtrain, observed (75% of data, )

 
54.80 
  • σtrain, observed (75% of data, )

 
69.79 
  • μtest, observed (25% of data, )

 
51.28 
  • σtest, observed (25% of data,

 
63.83 
  • μpredicted ()

 
50.91 52.43 
  • σpredicted ()

 
61.83 66.55 
  • RMSE ()

 
8.54 15.51 
  • NSE

 
0.98 0.94 
  • R2

 
0.98 0.95 
  • PBIAS

 
0.70% −2.24% 
Future period (October 1, 2014–September 30, 2015)   
  • μobserved ()

 
56.32 
  • σobserved (

 
57.93 
  • μpredicted ()

 
54.63 64.0 
  • σpredicted (

 
47.59 58.76 
  • RMSE ()

 
24.71 17.65 
  • NSE

 
0.82 0.91 
  • R2

 
0.83 0.93 
  • PBIAS

 
3.01% −13.64% 

Comparison of RF to other algorithms

The RF algorithm is compared to other machine learning algorithms, including XGBoost, SVR and ANN. Prediction performances of all four algorithms are presented. The distribution of errors due to the difference between observed and predicted streamflows in the historical period (25% of October 1, 2010–Sept. 30, 2014) for the SS and MS models is shown in Figure 8. Positive errors indicate overestimated streamflows, while negative errors indicate underestimated streamflows. Symmetrical and narrow distributions are ideally preferred with most errors concentrated around zero. For the SS model, RF and XGBoost algorithms have narrow curves while SVR and ANN algorithms' error distributions are wider (Figure 8(a)). For the MS model, although there are a few negative errors with the RF algorithm, most errors are around zero (Figure 8(b)). The RF algorithm has fewer errors compared to other machine learning algorithms for both SS and MS models.
Figure 8

Distribution of errors (observed–predicted) with RF, XGBoost, SVR, and ANN algorithms for (a) the SS model and (b) the MS model in the historical period (25% of October 1, 2010–September 30, 2014).

Figure 8

Distribution of errors (observed–predicted) with RF, XGBoost, SVR, and ANN algorithms for (a) the SS model and (b) the MS model in the historical period (25% of October 1, 2010–September 30, 2014).

Close modal
Average prediction error (Equation (6)), RMSE and runtime performances are compared in Figure 9. The runtime only includes time for running the algorithm and predicting Mac OS (2 GHz processor with 8 GB Ram). For the SS model, the RF algorithm has the smallest average prediction error and RMSE (Figure 9(a)). For the MS model, RF, SVR, and ANN algorithms have low average prediction errors, while the ANN algorithm has a greater RMSE than other algorithms (Figure 9(b)). For both models, the ANN algorithm has the slowest runtime. The runtime can change depending on model size and system specifications, but the relative proportion among algorithms stays constant. As also pointed out by Samadianfard et al. (2022), the RF algorithm performs at high speeds. The prediction performance of the developed RF algorithm is parallel to other studies by Erdal & Karakurt (2013) and Li et al. (2020):
(6)
where is the mean of predicted streamflows and is the mean of observed streamflows in the historical period (25% of October 1, 2010–September 30, 2014).
Figure 9

Average prediction error, RMSE, and runtime comparison of RF, XGBoost, SVR, and ANN algorithms for (a) the SS model and (b) the MS model.

Figure 9

Average prediction error, RMSE, and runtime comparison of RF, XGBoost, SVR, and ANN algorithms for (a) the SS model and (b) the MS model.

Close modal

The SS model with its derived input variables, including time variables, such as the day of the month and month of the year and statistical variables, such as maximum, mean and minimum values in a given month or year, from one streamflow station can successfully predict missing data scattered in its historical period. The MS model utilizes streamflows from nearby stations, and it can better forecast future streamflows. Adding more input variables and including more stations can improve the predictions of both models. When building ML models, it is better to start with many input variables and eliminate ones that have little impact on the prediction performance. Sharifi et al. (2017) discuss the optimal length of training and test sets and input combinations for ML applications in runoff prediction. Since machine learning algorithms require a large amount of data, the developed models may not be suitable for ungauged basins or basins with insufficient data.

RF-based machine learning models are developed to predict daily streamflows. The single-station (SS) model is built with variables derived from the time-series dataset of a single station (#1543). The multi-station (MS) model is built with variables, corresponding to streamflow observations of four other nearby streamflow stations. Predictions are made for two periods: historical and future. The historical period is inside the training period, where randomly selected 25% of the dataset is witheld. This portion represents missing historical values. The future period is one year of streamflow time series in daily time-step from October 1, 2014 to September 30, 2015. The MS model tends to overpredict streamflows with PBIAS of −2.24 and −13.64% in the historical and future periods, respectively. Both models can successfully predict missing periods in the historical period, where the SS model has an NSE and R2 of 0.98 and the MS model has an NSE of 0.94 and R2 of 0.95, while the MS model is superior in the future period with its NSE of 0.91 and R2 of 0.93, compared to the SS model's NSE and R2 of 0.82 and 0.83, respectively. The SS model is useful with its fewer data requirements to estimate the missing streamflow of a single station itself, while the MS model can be better utilized for future periods with its ability to better follow flow trends. Comparing RF to other ML algorithms, RF has a lower average prediction error and RMSE. Moreover, RF has less runtime than other compared algorithms, except for XGBoost. The developed algorithm is applied to the Kızılırmak River Basin. The open-source algorithm can also be easily applied to other basins to predict streamflow for desired locations and times.

The author acknowledges the helpful comments and suggestions from three anonymous reviewers to enhance the manuscript.

All relevant data are available from an online repository or repositories at https://github.com/msdogan/Stream-flow-prediction.

The authors declare there is no conflict.

Adnan
R. M.
,
Liang
Z.
,
Trajkovic
S.
,
Zounemat-Kermani
M.
,
Li
B.
&
Kisi
O.
2019
Daily streamflow prediction using optimally pruned extreme learning machine
.
Journal of Hydrology
577
(
July
),
123981
.
https://doi.org/10.1016/j.jhydrol.2019.123981
.
Adnan
R. M.
,
Liang
Z.
,
Heddam
S.
,
Zounemat-Kermani
M.
,
Kisi
O.
&
Li
B.
2020
Least square support vector machine and multivariate adaptive regression splines for streamflow prediction in mountainous basin using hydro-meteorological data as inputs
.
Journal of Hydrology
586
(
April 2019
),
124371
.
https://doi.org/10.1016/j.jhydrol.2019.124371
.
Besaw
L. E.
,
Rizzo
D. M.
,
Bierman
P. R.
&
Hackett
W. R.
2010
Advances in ungauged streamflow prediction using artificial neural networks
.
Journal of Hydrology
386
(
1–4
),
27
37
.
https://doi.org/10.1016/j.jhydrol.2010.02.037
.
Booker
D. J.
&
Woods
R. A.
2014
Comparing and combining physically-based and empirically-based approaches for estimating the hydrology of ungauged catchments
.
Journal of Hydrology
508
,
227
239
.
https://doi.org/10.1016/j.jhydrol.2013.11.007
.
Breiman
L.
2001
Random forests
.
Machine Learning
45
(
1
),
5
32
.
https://doi.org/10.1023/A:1010933404324
.
Breiman
L.
,
Friedman
J. H.
,
Olshen
R. A.
&
Stone
C. J.
1984
Classification and Regression Trees
.
Taylor and Francis Group
,
New York
.
https://doi.org/10.1201/9781315139470
.
Cacal
J. C.
,
Austria
V. C. A.
&
Taboada
E. B.
2023
Extreme event-based rainfall-runoff simulation utilizing GIS techniques in Irawan Watershed, Palawan, Philippines
.
Civil Engineering Journal
9
(
1
),
220
232
.
https://doi.org/10.28991/cej-2023-09-01-017
.
Chu
H.
,
Wei
J.
,
Wu
W.
,
Jiang
Y.
,
Chu
Q.
&
Meng
X.
2021
A classification-based deep belief networks model framework for daily streamflow forecasting
.
Journal of Hydrology
595
(
January
),
125967
.
https://doi.org/10.1016/j.jhydrol.2021.125967
.
Dalkiliç
H. Y.
&
Hashimi
S. A.
2020
Prediction of daily streamflow using artificial neural networks (ANNs), wavelet neural networks (WNNs), and adaptive neuro-fuzzy inference system (ANFIS) models
.
Water Science and Technology: Water Supply
20
(
4
),
1396
1408
.
https://doi.org/10.2166/ws.2020.062
.
Dogan
M. S.
2023
msdogan/Stream-flow-prediction: First release of streamflow prediction model. https://doi.org/10.5281/zenodo.7543339 (accessed 17 January 2023).
DSI
2022
State Hydraulic Works – Observed Streamflow Almanac
.
Available from: https://www.dsi.gov.tr/Sayfa/Detay/744# (accessed 12 November 2022)
.
Duarte
V. B. R.
,
Viola
M. R.
,
Giongo
M.
,
Uliana
E. M.
&
de Mello
C. R.
2022
Streamflow forecasting in Tocantins river basins using machine learning
.
Water Supply
22
(
7
),
6230
6244
.
https://doi.org/10.2166/ws.2022.155
.
Efe
R.
1996
Kızılırmağın Akım ve Rejim Özellikleri (Flow regime characteristics of Kizilirmak)
.
Öneri, Marmara Üniversitesi Sosyal Bilimler Enstitüsü
1
(
4
),
39
60
.
https://doi.org/10.14783/maruoneri.710445
.
Erdal
H. I.
&
Karakurt
O.
2013
Advancing monthly streamflow prediction accuracy of CART models using ensemble learning paradigms
.
Journal of Hydrology
477
,
119
128
.
https://doi.org/10.1016/j.jhydrol.2012.11.015
.
Feng
B. F.
,
Xu
Y. S.
,
Zhang
T.
&
Zhang
X.
2022
Hydrological time series prediction by extreme learning machine and sparrow search algorithm
.
Water Supply
22
(
3
),
3143
3157
.
https://doi.org/10.2166/WS.2021.419.
Govindaraju
R. S.
2000
Artificial neural networks in hydrology. II: hydrologic applications
.
Journal of Hydrologic Engineering
5
(
2
),
124
137
.
https://doi.org/10.1061/(ASCE)1084-0699(2000)5:2(124)
.
Hsu
K.
,
Gupta
H. V.
&
Sorooshian
S.
1995
Artificial neural network modeling of the rainfall-runoff process
.
Water Resources Research
31
(
10
),
2517
2530
.
https://doi.org/10.1029/95WR01955
.
Khullar
S.
&
Singh
N.
2021
Machine learning techniques in river water quality modelling: a research travelogue
.
Water Supply
21
(
1
),
1
13
.
https://doi.org/10.2166/ws.2020.277
.
Kumar
A.
,
Ramsankaran
R. A. A. J.
,
Brocca
L.
&
Muñoz-Arriola
F.
2021
A simple machine learning approach to model real-time streamflow using satellite inputs: demonstration in a data scarce catchment
.
Journal of Hydrology
595
,
126046
.
https://doi.org/10.1016/j.jhydrol.2021.126046
.
Li
Y.
,
Liang
Z.
,
Hu
Y.
,
Li
B.
,
Xu
B.
&
Wang
D.
2020
A multi-model integration method for monthly streamflow prediction: modified stacking ensemble strategy
.
Journal of Hydroinformatics
22
(
2
),
310
326
.
https://doi.org/10.2166/hydro.2019.066
.
Liaw
A.
&
Wiener
M.
2002
Classification and regression by randomForest
.
R News
2
(
3
),
18
22
.
Lin
Y.
,
Wang
D.
,
Wang
G.
,
Qiu
J.
,
Long
K.
,
Du
Y.
,
Xie
H.
,
Wei
Z.
,
Shangguan
W.
&
Dai
Y.
2021
A hybrid deep learning algorithm and its application to streamflow prediction
.
Journal of Hydrology
601
(
June
),
1
10
.
https://doi.org/10.1016/j.jhydrol.2021.126636
.
Ni
L.
,
Wang
D.
,
Wu
J.
,
Wang
Y.
,
Tao
Y.
,
Zhang
J.
&
Liu
J.
2020
Streamflow forecasting using extreme gradient boosting model coupled with Gaussian mixture model
.
Journal of Hydrology
586
(
December 2019
),
124901
.
https://doi.org/10.1016/j.jhydrol.2020.124901
.
Noori
N.
&
Kalin
L.
2016
Coupling SWAT and ANN models for enhanced daily streamflow prediction
.
Journal of Hydrology
533
,
141
151
.
https://doi.org/10.1016/j.jhydrol.2015.11.050
.
Panahi
J.
,
Mastouri
R.
&
Shabanlou
S.
2022
Insights into enhanced machine learning techniques for surface water quantity and quality prediction based on data pre-processing algorithms
.
Journal of Hydroinformatics
24
(
4
),
875
897
.
https://doi.org/10.2166/hydro.2022.022
.
Pedregosa
F.
,
Varoquaux
G.
,
Gramfort
A.
,
Michel
V.
,
Thirion
B.
,
Grisel
O.
&
Duchesnay
É
.
2011
Scikit-learn: machine learning in python
.
Journal of Machine Learning Research
12
,
2825
2830
.
Petty
T. R.
&
Dhingra
P.
2018
Streamflow hydrology estimate using machine learning (SHEM)
.
Journal of the American Water Resources Association
54
(
1
),
55
68
.
https://doi.org/10.1111/1752-1688.12555
.
Salmasi
F.
,
Nouri
M.
,
Sihag
P.
&
Abraham
J.
2021
Application of SVM, ANN, GRNN, RF, GP and RT models for predicting discharge coefficients of oblique sluice gates using experimental data
.
Water Supply
21
(
1
),
232
248
.
https://doi.org/10.2166/ws.2020.226
.
Samadianfard
S.
,
Mikaeili
F.
&
Prasad
R.
2022
Evaluation of classification and decision trees in predicting daily precipitation occurrences
.
Water Supply
22
(
4
),
3879
3895
.
https://doi.org/10.2166/ws.2022.017
.
Sayed
B. T.
,
Al-Mohair
H. K.
,
Alkhayyat
A.
,
Ramírez-Coronel
A. A.
&
Elsahabi
M.
2023
Comparing machine-learning-based black box techniques and white box models to predict rainfall-runoff in a northern area of Iraq, the Little Khabur River
.
Water Science and Technology
87
(
3
),
812
822
.
https://doi.org/10.2166/wst.2023.014
.
Schnier
S.
&
Cai
X.
2014
Prediction of regional streamflow frequency using model tree ensembles
.
Journal of Hydrology
517
,
298
309
.
https://doi.org/10.1016/j.jhydrol.2014.05.029
.
Shah
L. A.
,
Khan
A. U.
,
Khan
F. A.
,
Khan
Z.
,
Rauf
A. U.
,
Rahman
S. U.
,
Iqbal
M. J.
,
Ahmad
I.
&
Abbas
A.
2021
Statistical significance assessment of streamflow elasticity of major rivers
.
Civil Engineering Journal
7
(
05
),
893
905
.
https://doi.org/10.28991/cej-2021-03091698
.
Sharifi
A.
,
Dinpashoh
Y.
&
Mirabbasi
R.
2017
Daily runoff prediction using the linear and non-linear models
.
Water Science and Technology
76
(
4
),
793
805
.
https://doi.org/10.2166/wst.2017.234
.
Shijun
C.
,
Qin
W.
,
Yanmei
Z.
,
Guangwen
M.
,
Xiaoyan
H.
&
Liang
W.
2020
Medium- A nd long-term runoff forecasting based on a random forest regression model
.
Water Science and Technology: Water Supply
20
(
8
),
3658
3664
.
https://doi.org/10.2166/ws.2020.214
.
Sit
M.
,
Demiray
B. Z.
,
Xiang
Z.
,
Ewing
G. J.
,
Sermet
Y.
&
Demir
I.
2020
A comprehensive review of deep learning applications in hydrology and water resources
.
Water Science and Technology
82
(
12
),
2635
2670
.
https://doi.org/10.2166/wst.2020.369
.
Xu
W.
,
Chen
J.
,
Zhang
X. J.
,
Xiong
L.
&
Chen
H.
2022
A framework of integrating heterogeneous data sources for monthly streamflow prediction using a state-of-the-art deep learning model
.
Journal of Hydrology
614
,
128599
.
https://doi.org/10.1016/j.jhydrol.2022.128599
.
Yang
T.
,
Gao
X.
,
Sorooshian
S.
&
Li
X.
2016
Simulating California reservoir operation using the classification and regression-tree algorithm combined with a shuffled cross-validation scheme
.
Water Resources Research
52
(
3
),
1626
1651
.
https://doi.org/10.1002/2015WR017394
.
This is an Open Access article distributed under the terms of the Creative Commons Attribution Licence (CC BY 4.0), which permits copying, adaptation and redistribution, provided the original work is properly cited (http://creativecommons.org/licenses/by/4.0/).