1 Introduction

Deep learning technology is emerging all around us, strengthening the technical aspects of modern society, from time-series prediction to image analysis to natural language processing (Ren and Xu 2015; Ciregan et al. 2012; Krizhevsky et al. 2012; Bordes et al. 2012; Cireşan et al. 2012; Mikolov et al. 2013; Hadsell et al. 2008). This technology has been widely used recently in biological mechanisms, helping to solve problems that have previously been difficult to solve (Asgari Taghanaki et al. 2021; Tunyasuvunakool et al. 2021; Quang et al. 2015; Wang et al. 2020; Jaganathan et al. 2019). In addition, better algorithms have been developed for time-series prediction, such as recurrent neural networks (RNN), long short-term memory (LSTM), and gated recurrent units (GRU), which have shown strength in time-series predictions using deep learning based on big data accumulated in recent years (Oord et al. 1609; Bai et al. 1803; Borovykh et al. 1703; Mudassir et al. 2020; Li et al. 1707; Mudelsee 2019). To date, deep learning algorithms have been developed by focusing on the structure of the human brain, and the algorithms thus developed have generally performed well. The learning method of deep learning varies depending on the composition of the data because the method creates an optimal model based on the data. In the process of acquiring data, abnormal data may occur, such as those resulting from errors in sensors or abnormalities in the acquisition of the data. These are called outliers. Deep learning models are affected by learning performance if there is an outlier in the learning data. Many researchers training deep learning models remove outliers in the data to improve the learning performance of the models (Gharaei et al. 2022; Hendrycks et al. 1812; Pang et al. 2021). From an analyst's point of view in the environmental field, natural disasters are judged to be outliers because the period of data acquisition using sensors is much shorter than the longest patterns of the earth. These natural disasters occurred once in 100 years in the past, but they have occurred more frequently in recent years due to climate change. If deep learning expert judges natural disaster data as outliers and delete them to train deep learning model, that cannot predict natural disasters.

Therefore, we need a wisdom which we do not treat as outlier for natural disaster data, and we also need to develop deep learning model to analyze and predict natural disasters to consider the frequency and damage scale of natural disasters. These novel deep learning model should be designed by cause information of natural disasters and the correlation between inputs and outputs. The deep learning model also should not be judged as outlier even though the data from natural disasters come in.

In addition, to predict outliers (natural disasters), deep learning algorithms specializing in a single field and specialized algorithms for outlier values must be developed. As the climate changes, natural disasters such as floods and droughts occur more frequently, and these disasters seriously impact cities around rivers. Climate change is one of the major problems facing humans because the changing climate patterns are expected to increase the frequency of extreme weather events (Field et al. 2012; Palmer and Räisänen 2002). In recent years, the frequency of droughts caused by global warming has been increasing. River and groundwater levels are declining due to the increased water demand (Lauer et al. 2018). As a result, water shortages, ground subsidence, and penetration into the groundwater layer of seawater may occur (Shankar et al. 2011; Malyan et al. 2019; Abidin et al. 2001). In addition, global warming can add to the collision of cold and dry air currents at high latitudes and warm and humid air currents at low latitudes, causing frequent torrential rains and floods worldwide (Fowler and Hennessy 1995; Papalexiou and Montanari 2019; Myhre et al. 2019; Hoegh-Guldberg et al. 2018). For this reason, it is necessary to analyze and predict the flow of rivers to prevent damage from water depletion and natural disasters from floods. Therefore, in this paper, we propose novel PNP deep learning model to predict outliers (natural disasters) in the river flow prediction.

Since the PNP deep learning algorithm induces more accurate flow prediction by applying the correlation between precipitation and flow, we can apply this in the river flow prediction.

This paper is organized as follows. Section 2 introduces the deep learning algorithm used in time-series prediction and the study of predicting river flow through deep learning. Section 3 describes the introduction, composition, and formula of the PNP algorithm. Section 4 describes the input and flow data to be used in Sects. 5 and 6. Section 5 measures the performance of the PNP algorithm, proving that it outperforms the LSTM algorithm. Section 6 predicts the river flow using not only the PNP algorithm but also the LSTM based on several variables. Finally, Sect. 7 comments on the predictive results and provides directions for future research.

2 Related works

In this section, we introduce the deep learning algorithm used in time-series prediction and the study of predicting river flow through deep learning. The artificial neural network (ANN), the most basic concept of deep learning, was inspired by biological processes in the 1960s, when it was discovered that different visual cortical cells were activated when cats visualize different objects (Hubel and Wiesel 1962, 1959).

The study reviewed the links between the eyes and cells in the visual cortex and showed that information was processed hierarchically in the visual system. The ANN mimicked the recognition of objects by connecting artificial neurons inside layers that could extract object features (Rosenblatt 1958).

An ANN does not provide information on the sequential order of the input, so there are limitations in processing time-series data with dependencies between the data. Time-series data or strings are generally used to predict later data by the data entered earlier. Therefore, it is difficult to accurately predict time-series data using an ANN, which only disseminates the current input data in the order of input, hidden, and output layers. To address these problems, the RNN was proposed, an ANN designed to process temporally continuous data, such as time-series data (Elman 1990).

The RNN adds loop connections to each neuron in the hidden layer to input the hidden layer output from previous data back into the hidden layer neurons when predicting data from the present time. This allows an RNN to make predictions about current data simultaneously based on the data entered at a previous time. However, when backpropagation algorithms learn data covering a long period, the gradient can be abnormally increased or reduced. LSTM was proposed to solve the gradient problems that occur with RNNs, and most RNN-based applications proposed to date have been implemented using LSTM (Hochreiter and Schmidhuber 1997).

LSTM adds new elements such as a forget gate, input gate, and output gate to each neuron in the hidden layer to solve gradient-related problems. As the layer deepens, LSTM causes information loss because the encoder has too much information to compress and tends to use the information compressed by the encoder only for the initial prediction. Thus, bidirectional RNN (BRNN) and bidirectional LSTM (BLSTM) were developed (Schuster and Paliwal 1997).

Two-way BRNN and BLSTM add a backward processing layer to the existing RNN and LSTM layers, where the input data are transmitted to both forward and backward learning. This does not degrade the performance, even if the data are lengthy. LSTM has become a model that performs well even with data with long sequences while also solving the long-term dependence problem, but it requires more parameters than an RNN due to its complex structure. Overfitting can occur when there are not enough learning data. GRUs have been proposed to improve on these shortcomings (Chung et al. 2014).

DeepAR is an autoregressive RNN-based forecasting method that learns a global model from the historical data of all-time series in the dataset. This algorithm learns seasonal behaviors and dependencies on given covariates across time series; minimal manual intervention in providing covariates is needed in order to capture complex and group-dependent behavior (Salinas et al. 2020).

Temporal Fusion Transformer (TFT) is based on deep neural network (DNN) architecture for multi-horizon forecasting that achieves high performance while enabling new forms of interpretability. For multi-layer horizontal prediction, various types of data are used as TFT input. In addition, it was designed to consider various types of input values by supplementing the limitations of the existing model (Lim et al. 2021) (Table 1).

Table 1 Related deep learning algorithms

The following is a list of flow prediction studies using machine learning.

Fathian et al. analyzed time series using self-exciting threshold autoregressive (SETAR) and generalized autoregressive conditional heteroscedasticity (GARCH) models (Fathian et al. 2019). Then, they used multivariable adaptive regression splines (MARS) and random forest (RF) models to predict the monthly river flow of the Grand River’s Brantford and Galt Observatory in Canada. In addition, they developed hybrid models by combining MARS and RF models with SETAR and GARCH models, and they showed that the RF-SETAR models had the highest accuracy of the hybrid models.

Musarat et al. proposed a machine learning (ML) approach to predict water levels to prevent the devastation caused by extreme water levels rising in the Kabul River (Musarat et al. 2021). They used a variety of machine learning models, among used ML model, and they showed that ARIMA model has the highest performance.

Ghimire, S. et al. developed a new AI model based on LSTM and Convolution neural network (CNN) for hourly flow forecasts of the Brisbane River and Teewah Creek in Australia (Ghimire et al. 2021). They designed a prediction model based on six preceding values through statistical self-analysis of the time series from time-series data for the river flow. They also set different time intervals, such as one week, two weeks, four weeks, and nine months.

Huang et al. proposed deep learning models for flow prediction in astrophysics as an alternative to physically based models because the physically based models for flow prediction were relatively slow and costly (Huang et al. 2021). Their study used the SOBEK model which is physically based model and three neural network models: ANN, LSTM, and adaptive neural fuzzy inference system (ANFIS). They showed that the LSTM model had the highest accuracy.

Debbarma et al. utilized the gamma memory neural network (GMN) and genetic algorithm-gamma GMN (GA-GMN) to predict the daily flow rate (Debbarma and Choudhury 2020). They showed that the GA-GMN model performed better than the GMN model.

Senent-Aparicio et al. suggested that instantaneous peak flow (IPF) is very important for reducing flood damage and is combined with ML models and soil and water assessment tool (SWAT) simulations to suggest an approach to estimating IPF (Senent-Aparicio et al. 2019). They applied an ANN, ANFIS, support vector machine (SVM), and extreme learning machine (ELM) as the ML models and compared the performance.

Mehedi, Md Abdullah AI et al. predicted river flow in East Branch Delaware in United States (Mehedi et al. 2022). This paper predicted discharge time series up to 7 days in advance using a LSTM neural network regression model trained using over 80 years of daily data.

Le, Xuan-Hien, et al. constructed several models of LSTM and have applied these models to forecast discharge at the Hoa Binh Station on the Da River, one of the largest river basins in Vietnam (Le et al. 2019). LSTM models have been developed for one-day, two-day, and three-day flowrate forecasting in advance at Hoa Binh Station. Rainfall and flowrate at meteorological and hydrological stations in the study area are input data of the model.

Dodangeh, E. et al. proposed novel integrative models by coupling the resampling algorithms with ML models (to provide the more reliable flood susceptibility predictions compared to the one-time splitting train-test data set) with a case study at Ardabil province near the coastal margins of Caspian Sea (Dodangeh et al. 2020). This paper used random subsampling (RS) and bootstrapping (BT) algorithms, integrated with machine learning models: generalized additive model (GAM), boosted regression tree (BTR) and multivariate adaptive regression splines (MARS).

Kim, Donghyun, et al. used hydrological data observed in the upper Bokha interchange of the river to predict the flood level of Heungcheon Station located downstream of the Bokha River (Kim et al. 2022). Data on rainfall, water level, and discharge volume from 2005 to 2020 were collected from two observation stations for each upstream and downstream basin. In addition, we perform flood water level predictions at downstream points using machine learning models such as Gradient Boosting (GB), SVM, and LSTM.

Studies on river flow prediction using deep learning (Fathian et al. 2019; Musarat et al. 2021; Ghimire et al. 2021; Huang et al. 2021; Debbarma and Choudhury 2020; Senent-Aparicio et al. 2019; Mehedi et al. 2022; Le et al. 2019; Dodangeh et al. 2020; Kim et al. 2022) show that the algorithms used to predict river flow are limited in predicting outliers using data-based algorithms. Therefore, we propose the PNP algorithm, which can predict the flow of rivers using climate change-sensitive precipitation (Table 2).

Table 2 Related river flow prediction using deep learning

3 PNP algorithm

3.1 Characteristics of the PNP algorithm

On Earth, water always flows, and the process of water completing its cycle is called water circulation. This circulation is the continuous flow of water above and below the Earth's surface. It is usually caused by water evaporating from the sea and forming clouds, which transfer the water to land through rain. Once on land, the water flows over the surface of the earth to a lower place on the surface, forming a stream or a river. The stream's water flows downstream into the ocean, completing the water circulatory system. The time when water stays in this circulatory system is called the residence time. The average residence time in Korea is 1.5 weeks in the atmosphere and two weeks in the river. Even in the absence of precipitation, the river flow characteristics require a deep learning algorithm that can identify the characteristics of the water circulation system to predict the river flow. Therefore, we present the PNP algorithm, a new deep learning algorithm that considers the water circulation system and the residence time. The deep learning model consists of input, hidden, and output layers. The input data are fed into the input layer, and the output layer produces the model value. Hidden layers are made up of neurons composed of deep learning algorithms. The PNP algorithm can consist of neurons in the deep learning model, such as MLP, LSTM, and other deep learning algorithms. Figure 1 shows the layers and neurons of the deep learning model.

Fig. 1
figure 1

Layers and neurons of the deep learning model

The PNP algorithm focused on river flow that we present is divided into water entering the stream (positive water) and water exiting to the sea (negative water). If there is more positive water than negative water, the river becomes too full, which causes flooding, while more negative water than positive water leads droughts. We applied positive and negative water to the PNP algorithm, corresponding to the positive and negative neurons, respectively, and we also applied features from past precipitation data to consider the residence time.

The PNP algorithm is organized in a hidden deep learning layer, such as LSTM or RNN, consisting of positive and negative neurons in the hidden layer. Figure 2 shows the PNP algorithm concept. Both neurons receive the precipitation as input. Positive neurons analyze the increasing factor of the water flow in the river, while negative neurons analyze the decreasing factor. There is a line connected between the negative and positive neurons called the conveyor belt, which delivers the results of each neuron to the next node and provides past precipitation information. Through this process, we can reflect the amount of river emissions during the residence time. The conveyor belt provides the calculated value from the previous neuron to the next neuron. This is similar to the cell state in LSTM, which completely removes the cell state's information. However, unlike the cell state, the conveyor belt maintains the information and transfers it to the next neuron. Finally, when the last positive and negative neurons finish calculating, two results are generated from one node of the PNP hidden layer. Figure 3 shows the positive and negative neuron configuration diagram.

Fig. 2
figure 2

PNP algorithm concept

Fig. 3
figure 3

Positive and negative neuron configuration diagram

The positive and negative neurons are calculated in four steps: input, judgment, application, and transfer. The first step of the positive neuron is the input step, which is given to the neuron and multiplied by the weighted value \(w\). The second step is the judgment by applying the \(sigmoid\) function, using the value one if the need is high and zero if it is low. The third step is the application step, which adds the value of the sigmoid function, the positive bias term, \({b}_{p}\), and the value from the previous positive conveyor belt. Finally, in the fourth step, we remove a negative element by applying a rectified linear unit (ReLU) function to the value calculated in the third step. The values removed by the ReLU are transferred to the conveyor belt and the next neuron. The negative neuron follows the same process through the second computational step, but in the third step, \({b}_{n}\) is added to the negative bias term rather than the positive bias term, \({b}_{p}\). The fourth step is applied to prevent the quantity value. Equations (1)–(4) show the calculation of positive neurons, while Eqs. (5)–(8) show the calculation of negative neurons.

$$ {\text{fs}}_{p} = I \times w_{p} $$
(1)
$$ {\text{ss}}_{p} = {\text{sigmoid}}\left( {a_{p} } \right) \times {\text{fs}}_{p} $$
(2)
$$ {\text{ts}}_{p} = {\text{ss}}_{p} + \left| {b_{p} } \right| + {\text{PCb}}_{{\left( {t - 1} \right)}} $$
(3)
$$ {\text{Ls}}_{p} = {\text{Relu}}\left( {{\text{ts}}_{p} } \right) $$
(4)
$$ {\text{fs}}_{n} = I \times w_{n} $$
(5)
$$ {\text{ss}}_{n} = {\text{sigmoid}}\left( {a_{n} } \right) \times {\text{fs}}_{n} $$
(6)
$$ {\text{ts}}_{n} = {\text{ss}}_{n} + \left| { - b_{n} } \right| + {\text{NCb}}_{{\left( {t - 1} \right)}} $$
(7)
$$ {\text{Ls}}_{n} = - {\text{Relu}}\left( { - {\text{ts}}_{n} } \right) $$
(8)

In Eqs. (1)–(8), \({\mathrm{fs}}_{p}\) and \({\mathrm{fs}}_{ n}\) are the first step in the PNP algorithm computational process, \({\mathrm{ss}}_{p}\) and \({\mathrm{ss}}_{n}\) are the second step, \({\mathrm{ts}}_{p}\), \({\mathrm{ts}}_{n}\) are the third step, and \({\mathrm{Ls}}_{p}\) and \({\mathrm{Ls}}_{n}\) are the final step. \({w}_{p}\) and \({w}_{n}\) are the positive and negative weighted values, respectively. \({a}_{p}\) \(\mathrm{and}\, {a}_{n}\) are the positive and negative sigmoid functions, respectively. \({b}_{p}\) and \({b}_{n}\) are the positive and negative bias terms, respectively. \(I\) is the input data, \({\mathrm{PCb}}_{(t-1)}\) represents the previous positive conveyor belt value, and \({\mathrm{NCb}}_{(t-1)}\) represents the previous negative conveyor belt value.

3.2 Deep learning configuration of PNP algorithm

PNP algorithms can be configured as hidden ANN layers, and the number of nodes can be adjusted, as in other deep learning algorithms such as MLP, LSTM, and GRU. Figure 4 shows the hidden layers and internal nodes comprising the PNP algorithm. The input value of the PNP algorithm is entered in three dimensions, as with the LSTM algorithm. The input data dimensions consist of the data size, variable, and time step. The data size is the amount of data in time units used in the algorithm. The variable represents the number of variables. The time step is the number of past data points used, for which we must consider the residence time of the river flow. We can designate the number of neurons in positive and negative time steps through the time step value. The neuron array is organized in a parallel format based on the number of variables. The neuron array has a two-dimensional structure composed in a series according to the time step. Figure 5 shows the algorithm structure according to the number of variables and neurons.

Fig. 4
figure 4

Hidden layers and internal nodes comprising the PNP algorithm

Fig. 5
figure 5

Algorithm structure according to the numbers of variables and neurons

4 Acquired data characteristics

To predict the river flow through deep learning, we must consider the correlation between the target value and the input variables. Because the river flow includes the circulation process of water and the characteristic of flowing from upstream to downstream, we should select input variables that have such a characteristic of water or affected. The water circulation process is largely determined by weather (water quantity, temperature, etc.) and the upstream impact of dams, depending on how the dams operate. Therefore, we collected river flow data, weather observation data closest to the flow measurement point, and upstream dam operation data to predict the river flow. In addition, we obtained datasets from three regions (Hangang Bridge, Yeoju Bridge, and Gangchung Bridge) to generalize the performance evaluation of the algorithms.

4.1 River flow

We acquired data measured at the Hangang, Yeoju, and Gangchung Bridges in Korea. The Hangang Bridge (37°31′03.3"N, 126°57′31.7"E), located over the Han River in Seoul, has a total length of 1,005 m. The Han River is the second longest river in South Korea (494 km) and the largest river in terms of flow and basin. The Han River has hundreds of tributaries, including the Bukhan and Imjin Rivers, across four regions: Gyeonggi, Gwandong, Haeseo, and Hoseo. The Yeoju Bridge (37°29′81.7"N, 127°64′81.4"E) is located at the southern end of the Namhan River from Sangdong to Cheonsong-dong, Yeoju-si, Gyeonggi-do. The Gangchung Bridge (36°82′16.1"N, 126°93′36.6"E), which crosses the Gokgyo river in Yeomchi, is 325 m long and 10 m wide. The blue color in Fig. 6a indicates the Han River, and the red checkpoints indicate the locations of the Hangang and Yeoju Bridges. The blue color in (b) indicates the Gokgyo river, and the red checkpoint indicates the location of the Gangchung Bridge. The Hangang and Yeoju Bridges are located in the same Han River area, but there are differences in upstream and downstream, and the Gangchung Bridge is located in a different basin. The Hangang Bridge is the largest by region, followed by the Yeoju Bridge, and finally, the Gangchung Bridge is the smallest.

Fig. 6
figure 6

a Map of the Han River basin and location of the Hangang and Yeoju Bridges; b map of the Gokgyo River basin and location of the Gangchung Bridge

The river flow data were provided by the Han River Flow Control Office for the period 1/1/2010–12/31/2020. The unit of the data is one day and is in the form of 4018 int. Table 3 shows the information of the acquired river flow data, and Fig. 7 shows the obtained river flow graph.

Table 3 Analysis of river flow (\({m}^{3}/s\)) data obtained
Fig. 7
figure 7

River flow graph (2010–2020)

4.2 Weather

As Korea is in the mid-latitudes of the northern hemisphere, changes are evident in all four seasons, with periodic characteristics throughout the year as the seasons change. We used the weather observation data closest to the river flow measurement area and collected data from the Korea Meteorological Administration. Figure 8 shows the locations of the weather station and the flow station, and Table 4 summarizes the weather data.

Fig. 8
figure 8

Locations of river flow observatories and weather stations: a Hangang Bridge, b Yeoju Bridge, and c Gangchung Bridge

Table 4 Analysis of weather data acquired

4.3 Upstream dam hydrological data

Dams reduce the peak flood of downstream rivers during flooding and provide water for continuous river maintenance during droughts. They affect downstream changes in spill characteristics in the short term. On the other hand, they also increase flows in the dry season for the long term caused by increased low flows. For this reason, we must use upstream floodgate information as an input variable to predict the flow of the stream. Thus, we collected upstream dam operation data around the flow observation point. We used hydrological data provided by the Korea Water Resources Corporation and Korea Hydro & Nuclear Power for the dams upstream on the Han River. Figure 9 shows the location of the dams on the Han River, and Table 5 summarizes the data from the dam.

Fig. 9
figure 9

Location of the dams in the Han River basin

Table 5 Analysis of discharge (\({m}^{3}/s\)) data of the dams upstream from the Hangang Bridge

There are 10 dams upstream from the Hangang Bridge, three dams upstream from the Yeoju Bridge (the Hoengseong, Chungju, and Goesan Dams), and none upstream from the Gangchung Bridge.

5 Performance verification of the PNP algorithm

5.1 Algorithm performance verification pipeline configuration

We built a pipeline to verify the algorithm performance. The pipeline sequence is divided primarily into the data and deep learning processes. Figure 10 indicates the configuration of the algorithm performance verification pipeline. The first step of the data process divides the acquired data into learning and test data in an 80:20 ratio. The learning data are used to train the deep learning model, and the test data are used to verify the model performance. We also applied K-fold cross-validation to prevent data with high noise values from being concentrated on one side when dividing the learning and test data and overfitting to a specific dataset. K-fold cross-validation creates K divisions of the learning and test data. In this paper, we organized five types of K-folds, and we also designated the same ratio for the learning and test data. However, we designated different locations for the test data. Figure 11 illustrates the K-fold cross-validation where K = 5.

Fig. 10
figure 10

Performance verification of the algorithm pipeline configuration

Fig. 11
figure 11

K-Fold cross-validation where K = 5

We organized a preprocessing model for the learning data. The preprocessing model is for standardization, using the learning data divided between learning and validation in a 60:20 ratio. Figure 12 shows the division of the acquired data.

Fig. 12
figure 12

Division of acquired data

We divided the acquired data into learning and testing data and the learning data into training data and validation data. The learning data were used to construct preprocessing models, and the training data were used to train the models. The validation and testing data were used to measure the performance of the deep learning model, with the validation data used in constructing or training the model. Validation data were used for preprocessing and training the deep learning model, for which the testing data were not involved. After applying the training, validation, and test data to the preprocessing model, we built a dataset to fit the input of the deep learning model. We organized the data building in three dimensions, namely, the data size, variable, and time step, to fit the PNP algorithm input requirements. The time step must be selected considering the residence time in the river. The average residence time in Korean rivers is 14 days; thus, we designated 14 days as the time step. In this study, we designated the variable value as one because the input value to be entered into the PNP algorithm is one of the closest precipitation points to the river flow observation point. The total data size is 3977 data records based on the past data considering the time step. Therefore, the size of the input data of the training, verification, and testing datasets was [2386, 1, 14], [795, 1, 14], [796, 1, 14].

The first stage of the deep learning process is the model configuration. We constructed the model with the PNP and MLP algorithms, designating 50 nodes for each algorithm. We used the Adam optimizer and mean squared error for error measurement. We used another deep learning which LSTM algorithm with excellent performance in time-series prediction to compare the performance.

LSTM algorithm is a derivative RNN algorithm, which consists of three gates: Input Gate, Output Gate, and Forget Gate. If the (t-1) hidden layer of Fig. 13 is affected by the (t) hidden layer, it adds a calculation that erases it. We constructed a model like the PNP and MLP algorithm, and this model is composed of the LSTM and MLP algorithm. This model consisted of LSTM and MLP algorithms, with the number of nodes set to 50. Figure 14 shows the configuration of the model, with Fig. 14a representing the model using the PNP algorithm and Fig. 14b showing the model using the LSTM algorithm.

Fig. 13
figure 13

Structure of LSTM

Fig. 14
figure 14

Model composition using a the PNP algorithm and b the LSTM algorithm

After constructing the model, we used the training and validation data to train it. We input the trained model as test data to predict the river flow and then applied reverse preprocessing. We then measured the error by comparing the reverse-prediction result with the actual river flow value using RMSE and sMAPE for error measurement. We compared the predictive results of the two models with two error-measurement methods to demonstrate the PNP algorithm performance. Equation (9) represents the preprocessing, and Eq. (10) represents the reverse preprocessing. Equation (11) represents RMSE, and Eq. (12) represents sMAPE.

$$ {\text{Preprocess}} = \frac{{{\text{ID}} - {\text{LD}}_{{{\text{mean}}}} }}{{{\text{LD}}_{{{\text{std}}}} }} $$
(9)
$$ {\text{Reverse preprocess}} = {\text{PD}} \times {\text{LD}}_{{{\text{std}}}} + {\text{LD}}_{{{\text{mean}}}} $$
(10)
$$ {\text{RMSE}} = \sum \sqrt {\left( {{\text{PD}} - {\text{RD}}} \right)^{2} } $$
(11)
$$ {\text{sMAPE}} = \frac{{\left| {{\text{PD}} - {\text{ RD}}} \right|}}{{\left( {\left| {{\text{PD}}} \right| + \left| {{\text{RD}}} \right|} \right)/2}} \times 100 $$
(12)

In Eqs. (9)–(12), \(\mathrm{ID}\) is the training, verification, and test data, while \({\mathrm{LD}}_{\mathrm{mean}}\) represents the average value of the learning data and \({\mathrm{LD}}_{\mathrm{std}}\) represents the standard deviation. \(\mathrm{PD}\) indicates the prediction value of the model using the test data, and \(\mathrm{RD}\) indicates the river flow data.

5.2 Verification results

Table 6 gives the RMSE and sMAPE prediction results for the two models. \({E}_{1},{E}_{2},{E}_{3},{E}_{4},{E}_{5}\) represent the K-fold cross-validation in Fig. 11, respectively, while \({E}_{\mathrm{mean}}\) represents the average value of \({E}_{1},{E}_{2},{E}_{3},{E}_{4},{E}_{5}\). The error of the PNP model was lower than that of LSTM for the Hangang, Yeoju, and Gangchung Bridges. Thus, we proved that the PNP algorithm performed better than the LSTM algorithm in predicting the river flow using precipitation.

Table 6 Comparison of model prediction errors

Table 7 represents calculation of RMSE and sMAPE based on average value of river flow (Hangang, Yeoju, Gangchung). Through Table 7, we can compare the prediction performance of PNP and LSTM model in case of natural disasters (flood) and non-natural disasters (daily life).

Table 7 Prediction errors according to river flow range

As a result of the measurement, the prediction performance of river flow of the PNP model was higher than LSTM model, except for cases, the average value of the river flow at the Hangang Bridge below.

For sMAPE, the size of river is larger; we can confirm that the prediction performance of PNP model is relatively higher than LSTM model when the river flow is below the average value.

This means that as the size of a river is larger, there are more tributaries. The more tributaries mean that there are more areas to consider precipitation. However, in this paper, we used one precipitation as input, so the error of the PNP algorithm was measured to be larger than the LSTM algorithm.

Table 8 shows sMAPE according to river flow range; we can judge the total prediction performance according to river flow range through Table 8. When the river flow is above the average value, the PNP model showed 10% lower error than the LSTM model. Also, when the river flow is below the average value, the PNP model showed a little higher error than LSTM model, about 3%. From this, we can see that when the river flow is above the average value, the prediction performance of PNP model is excellent compared to LSTM model.

Table 8 sMAPE according to river flow range

Figures 15, 16, and 17 show the prediction of river flow of the PNP&LSTM algorithm for the Hangang Bridge, Yeoju Bridge, and Gangchung Bridge, respectively.

Fig. 15
figure 15

Prediction of deep learning algorithms (PNP & LSTM) and test data of the Hangang Bridge

Fig. 16
figure 16

Prediction of deep learning algorithm (PNP & LSTM) and test data of the Yeoju Bridge

Fig. 17
figure 17

Prediction of deep learning algorithm (PNP & LSTM) and test data of the Gangchung Bridge

We confirmed the overall high predictive performance of models using the PNP algorithm. Figure 18 shows a predictive error comparison graph of the two models where (a) shows the RMSE and (b) shows the sMAPE. To verify the performance of the model, we measured the prediction errors in both models: for the Hangang Bridge, the RMSE and sMAPE were 57.927 and 2.565, respectively; for the Yeoju Bridge, the RMSE and sMAPE were 46.457 and 3.031, respectively; and for the Gangchung Bridge, the RMSE and sMAPE were 19.333 and 8.901, respectively.

Fig. 18
figure 18

Results of RMSE and sMAPE Errors

6 Prediction of river flow

In this section, we constructed a prediction model of the river flow using temperature, humidity, and upstream dam hydrological data as well as precipitation. We composed two models to compare the performance, as shown in Fig. 19, including the PNP (a) and LSTM (b) algorithms.

Fig. 19
figure 19

Composition of the two models

Model (a) in Fig. 19 uses the PNP algorithm, which consists of three input layers: precipitation, weather (excluding precipitation), and upstream dam hydrological data. The PNP uses the hidden layer connected from the input precipitation layer, while the LSTM uses the hidden layer connected to the weather and upstream dam hydrological data input layers. Because the PNP algorithm is based on the correlation between precipitation and river flow, we do not use the PNP algorithm for the hidden layers of weather and upstream dam hydrological data. There are 10 dams upstream of the Hangang Bridge and three upstream of the Yeoju Bridge. There is no upstream dam input layer for the Gangchung Bridge because it has no upstream dam. We used the PNP algorithm for the hidden precipitation layers, while we used the LSTM algorithm for the hidden layers of the remaining weather (excluding precipitation) and operational information regarding the upstream dams. Finally, we organized a deep learning model with two hidden MLP layers and one output layer. The model in Fig. 19b used the LSTM algorithm rather than PNP, and the remainder of the deep learning configuration was identical to the model in Fig. 19a. We divided the data into a 60:20:20 ratio for training, verification, and test data. Figure 20 shows the flow data from the Hangang, Yeoju, and Gangchung Bridges into training, verification, and test data. Table 9 represents the output shape of the deep learning layer of the models in Fig. 1a and b.

Fig. 20
figure 20

Training, verification, and testing precipitation data

Table 9 Type of input data and output shape of the model

Table 10 shows the model's prediction error, and Figs. 21 and 22 show the model's prediction and flow measurement.

Table 10 Prediction error of the model
Fig. 21
figure 21

Prediction and observation values of the training and validation data

Fig. 22
figure 22

Prediction and observation values of the test data

As a result of the experiment, it can be determined that both the PNP model and the LSTM model have p-value < 0.05, which means that the prediction of both models is significant. And we concluded that the PNP model performs better than LSTM, according to both RMSE and sMAPE. Figure 23 shows a predictive error comparison graph of the two models, where (a) shows the RMSE and (b) shows the sMAPE. To verify the performance of the model, we measured the river flow prediction performance by constructing a model using the LSTM algorithm and measured the prediction errors in the two models: for the Hangang Bridge, the RMSE and sMAPE were 18.352 and 0.13, respectively; for the Yeoju Bridge, the RMSE and sMAPE were 6.125 and 0.628, respectively, and for the Gangchung Bridge, the RMSE and sMAPE were 0.382 and 0.035, respectively. We confirmed that overall, the prediction error of the model using the PNP algorithm was low.

Fig. 23
figure 23

Results of models using PNP and LSTM algorithms

7 Conclusion

This paper presented a PNP algorithm based on an understanding of hydrology to predict river flow. We developed the PNP algorithm considering precipitation with the river flow, the length of water residence time, and other variables. The PNP algorithm consists of positive and negative neurons that consider the water circulatory system. We applied a conveyor belt, which uses past data to consider the residence time in the river. The input value of the PNP algorithm is entered in three dimensions, as with LSTM, and the dimensions of the input data are the data size, variable, and time step. We acquired input and output data to train the deep learning model. The output is the river flow data measured at the Hangang Bridge, Yeoju Bridge, and Gangchung Bridge, and the input data use the weather data from the near river flow measurement point and the operational data of upstream dams. We also used K-fold cross-validation to measure the model performance accurately. We constructed two models to verify the performance of the PNP algorithm. One was a model composed of PNP algorithms, and the other was a model composed of LSTM algorithms. We compared the average values by measuring the performance of the models with RMSE and sMAPE with five datasets generated by K-fold cross-validation.

We measured and compared RMSE and sMAPE based on the average value of river flow for three sectors (Hangang Bridge, Yeoju Bridge, Gangchung Bridge). As a compared result, we can see that the prediction performance of river flow for PNP model is superior to LSTM model except for cases, the average value of the river flow at the Hangang Bridge below. The greater the river flow, the more tributaries, and the more tributaries means that there are more areas to consider the amount of precipitation. However, since one amount of precipitation is input in this study, the error of the PNP algorithm is judged to be larger than that of the LSTM algorithm.

When the river flow is less than the average value, we confirmed the prediction of errors for large scale of river has a little higher error than LSTM model. Also, when we compared the total item by using sMAPE, we confirmed the PNP model has a 10% lower error than the LSTM model when the river flow is above the average value. In addition, when the river flow is below the average value, the PNP model showed a little higher error than LSTM model, about 3%. Through this, we confirmed that the PNP model has better prediction performance than other deep learning model such as LSTM. Thus, we confirmed that the prediction performance is higher when the river flow is high (natural disaster). Through this paper, we proved that the performance of the PNP algorithm, which is designed for the correlation between precipitation and flow, was excellent compare to LSTM.

Partially, the PNP algorithm sometimes performs worse than the LSTM algorithm because it only calculates the precipitation in the target area. In order to solve this problem, it is necessary to consider not only the precipitation data at the flow prediction point but also the precipitation data at the upper point of the river.

In the future, to upgrade the PNP algorithm, we need to design it by considering the data upstream of the river as well. In addition, we need to develop a deep learning algorithm designed to correlate not only precipitation, but also humidity, upstream dam operation, etc. like the PNP algorithm.