{'fraction_non_alphanumeric': 0.019311377245508982, 'fraction_numerical': 0.006661676646706587, 'mean_word_length': 4.8344978165938866, 'pattern_counts': {'":': 0, '<': 0, '<?xml version=': 0, '>': 0, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 1, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
Artificial Neural Networks for Urban Water Demand Forecasting: A Case Study

This paper presents an application of an artificial neural network model in forecasting urban water demand using MATLAB software. Considering that in any planning process, the demand forecast plays a fundamental role, being one of the premises to organize and control a set of activities or processes. The versatility of the short, medium and long-term prediction that is provided to the company that offers the water distribution service to determine the supply capacity, maintenance activities, and system improvements as a strategic planning tool. Shown to improve network performance by using time series water demand data, the model can provide excellent fit and forecast without relying on the explicit inclusion of climatic factors and number of consumers. The excellent accuracy of the model indicates the effectiveness of forecasting over different time horizons. Finally, the results obtained from the Artificial Neural Network are compared with traditional statistical models.


Introduction
At present, water forecasting is very important, being crucial for the supply in any distribution system. The consideration of forecasting time periods supports the planning of supply capacity, scheduling, tariff adjustment and optimization of the activities of a company that provides water distribution service [1][2].
One of the purposes of the forecast made by the companies is to match supply with demand for water and provide a quality service for consumers [3]. Responding efficiently to current needs, which have become very inconsistent, reason for which the flexibility and adaptability of companies is fundamental, especially in urban areas that trace high population growth as it will influence the future distribution of urban water service and should be included in a planning for activities have a logical and efficient development, in addition to sustainable management of natural resources [4][5].
The usefulness of making long-term forecasts points to obvious factors for evaluating the effectiveness of conservation measures that will influence the generation of policies and strategies such as the price of water [6]. In the development of projects of the companies that provide the distribution service, the projection of consumption is important, since areas are not always supplied from a single source; several sources can supply many consumers [7]. This work focuses on the forecast of water demand in the medium term, these allow optimal operations of extraction, collection and distribution of water resources. Helping to develop strategies for water demand management in the medium term. The stages of a system of this type include the collection of raw water, production, regulation and distribution of urban water. For this reason, various controls can be carried out within the process and the forecast supports decision-making in the medium term. As well as implementing restrictions on water use in times of drought or thermal stress [8][9].
Short-term demand forecasting has traditionally used linear regression models, such as multi-line regression and integrated autoregressive moving average model (ARIMA). These methods remain the most common according to Adamowski and Chan [7], but the invalidity of linear regression models to adequately account for nonlinear parameters. Non-stationary water demand data have generated an examination of other models. Jain and Ormsbee [2] applied artificial neural networks (ANNs) in the short-term forecast of urban water demand to address nonlinearity [4]. Research has generally shown that ANNs outperform linear regression techniques in forecasting urban water demand [10][11][12].
Medium-term (weekly and monthly) urban water demand forecasts help water managers make more informed water management decisions when balancing the needs of water supply, residential/industrial demands, and stream flows for fish and other habitats [13]. Accurate forecasts also aid with decision making [1][2]6]. Urban water is generally supplied based on the experience of operators, although accurate and reliable forecasts of water demand helps operators provide water more sustainably [13]

Development of the urban water forecast model
The development of the ANNs model has the purpose of forecasting urban water demand taking into account the variables that are handled as the volume of urban water consumed, being fundamental to determine the time horizon of the prediction and also the level of reliability of the model that influences decision making in the company.
This model, neuron j receives a series of inputs (X 1 , X 2 , ..., X n ) the temporal variables of months and years of the volume of urban water consumption. Where each input signal must be multiplied by the weight associated with its connection (W 1 , W 2 , …, W n ) depending on the weights found in relation to the learning process. Then, these weighted inputs are added, and the activation function is applied to them to return an output from the input values.
The inputs to the network generate a link with the next neuron that can pass through the connection of a hidden layer and that output is represented according to the weighting of the neuron connection and the previous layer, as shown below: ( ) (1) X 1 is the input vector of layer 1 and W 1j corresponds to the weights that relate to the first neuron, to neuron j of the second layer. The function F 2j is the one that corresponds to the activation of neuron j of the second layer. Likewise, with the neurons of the second layer. Each neuron i of the output layer must generate a value output as we can see in the following equation: ( ) (2) Where W 2i is the vector of weights that are related to the connections that go from the neurons of the second layer to the neuron i of the output layer, S 2 is the vector of output of the neurons of layer two. This become inputs of the neurons of the output layer.

ANN forecast process
The neural network prediction model will be established according to the influencing factors, considering within the inputs the factors that affect demand, and the expected demand as an output. Figure 1 shows the process proposed for forecasting using neural networks. In it they indicate the factors to be considered as the identification and preprocessing of the information with which the time horizon of the prediction is analyzed. Once the variables have been identified, the neural network technique is applied, taking into account the values that make up the training, validation and test sets, thus determining the architecture of the network and using these criteria, training is carried out on the artificial neural network model for urban water forecast model.
The database of urban water demand in the preparation of the forecast is very important for its decisive value in the prediction. The input variables are fundamental in the process, in this case, the amount of urban water demand, as a quantitative variable measured in m 3 .
Customers, depending on the sector in which they are located, are coded by a plan and the route of the distribution system. The sectorization for the case study is the urban area. Based on the plan and the distribution route, the data are ordered and grouped based on a general matrix of customers for each year with the corresponding volumetric consumption.

Figure 1. ANN forecast process
It is necessary to pre-process the data before entering them into the software so that they are in a noise-free format (without null or inconsistent values) in order to prepare them for the forecast With the definition of the training sets, the network carries out the process of learning the trends and patterns of the data, in this case it is 70% of the data that represent the first 42 months, in this case it is 70% of the data that represents the first 42 months. The validation set is basically used for the conclusive verification stage of the network, where the data are the consequent values to those of the training which in this case represent 15% of the values that are the following 9 months. The test set is the data remaining after taking the values in the training process. The purpose of this set is to evaluate the accuracy of the network. It is composed of the last 9 months representing 15% of the data.
There are many ways to establish the architecture of a neural network, in most cases backpropagation training algorithms are used. In this case study, the Levenberg Marquardt retropropagation algorithm will be used.

Figure 2. ANN Architecture
The input variables for the forecast of urban water that in this case will be two as shown in Figure 2, corresponding to the number of input neurons. A hidden layer is shown so that a better performance is generated since with the increase of hidden layers the processing time is increased and an overadjustment is obtained causing a deficient performance of the prediction. In this case there are 10 hidden neurons that represent the necessary condition so that the principle of entropy minimization is conserved in the presence of retropropagation. The number of output neurons in our network is one, because the value of the selected variable is predicted so that the network precision is not diminished. In this paper, the MSE and Coefficient of Correlation (R 2 ) were used to evaluate the prediction effect of the model.

Assessment criteria
Where n is the number of samples and ̂ is the estimate of From the above formula it follows that the measurement loss function is the quadratic or mean square error. Coefficient of Correlation (R 2 ), being: Where ŷ is the forecasted demand, is the measured demand, is the mean of the demand forecasting, and n is the number of observations. Low values are better while the closer to zero means there is no error. Regression analysis R is performed to measure the correlation between outputs and targets. The goal of training is to find the least error in the function of weights between neurons unless you have an over-adjusted model. The training uses a descending gradient technique of the retropropagation algorithm. Table 2 shows the results of the forecasting urban water demand model based on artificial neural networks. They are analyzed considering the two important criteria such as MSE and R 2 to compare them with those of the ARIMA time series model. To conclude with the implementation of the model, the network performance graphs are presented in Figure 3, as training error decreases through iterations.  Figure 4 it is possible to see how the correlation coefficient is 0.99493 which is very close to 1, which indicates that there is a high level of correlation between real and predicted values.

Figure 4. Correlation between actual values and forecast
The forecast of the artificial neural networks is presented with greater equivalence in the behavior of the real demand of urban water consumption of the company, since the behavior of the forecast in the ARIMA model tends to soften and overadjust the model, this by the moving averages with which the model is predicted and tendency to become a prediction of constant values. In the artificial neural networks model the data are self-trained and validate the patterns of behavior and at the end they are evaluated to progressively determine the best prediction option. As shown in the figure 5 below: The comparison between the ANN model and the ARIMA model, the fundamental criterion is that the MSE. It must be as close to zero as possible, and the predicted values are closer to the actual values. So, it is evident that the artificial neural networks model with a 0.471 is better than the one thrown by the ARIMA model of 0.769. In addition, it is appreciable that using the ANN model provides a much higher level of reliability than that exposed by the classical statistical model as shown in Table 3. As for the correlation between the predicted value and the real value determines the force and direction of the relationship between these values. As long as the correlation values are close to 1, it means that the predicted data are behaving with greater relation to the sense of the real values with the artificial neuronal networks model the correlation is 0.98, while the value of the correlation with the ARIMA model is 0.55, which indicates a better relation in the sense and force of the level of relation of the predicted values with the ANN model.

Conclusions
The application of Artificial Neural Networks as a prediction technique to develop the forecasting urban water demand, where dependent and independent variables were analyzed that were processed in the construction of the network through the processes of training, validation and testing of the network, obtaining results that behave with greater similarity to actual consumption.
With the analysis and comparison of the results obtained with the ANN model and the ARIMA the differences and similarities between them are determined and the interpretation of the results is facilitated. These results thrown by the ANN model presents greater similarity in the behavior of real consumption, while the results of the ARIMA model tend to soften and over fit, so they become constant predictions by the moving average with which they are calculated.