# Road Infrastructure Investment Limits Based on Minimal Accidents Using Artificial Neural Network
## 2 Data and Methodology
### Artificial Neural Network (ANN) Modeling  
A feed-forward 2-layer ANN with 7 neurons was developed in MatLabTM (R2017a) to train the annual road accident model. Based on the balanced performance between the training and testing results, the number of neurons was optimized. This was achieved by varying the number of neurons, randomly re-splitting the training/testing data, and retraining with random initial conditions. A schematic of the final ANN structure is shown in Figure 1. The terms W and b represent the weight and bias matrices of the model, respectively. Each of the variables from the input matrix \(X\) is connected to each neuron through the weight matrix \(IW\). In this case, \(a^{1}\) is a 7-element column vector formed by \"\(F^{1}\)\" from the weighted sum of the input variables \(x_{i}\) and bias \(b_{i}\) of the neurons' outputs. The neurons' outputs serve as inputs, which are transformed to fall between \([-1,1]\) using the hyperbolic tangent sigmoid equivalent transfer function \"\(F^{1}\)\" given by Equation (3). This quickens the learning process. These normalized outputs from \"\(F^{1}\)\" serve as input to the output layer. \"\(F^{2}\)\" is a purelin transfer function that again normalizes the weighted sum and biases of the outputs from the hidden layer between \([-1,1]\) to yield \(a^{2}\). Equation (4) is a post-processing function that reverses \(a^{2}\) to yield a scalar \(y_{p}\) between \([y_{max},y_{min}]\) that is matched and compared with the actual target (ARA) \(y_{a}\). The training cycles follow this sequence while the weight and bias matrices are optimized for better model performance. Bayesian-regularized (BR) Levenberg-Marquardt optimization was selected as the training algorithm [41,42]. The BR-ANNs were found to be robust and difficult to over-train or over-fit, and the validation process is unnecessary [43]. Data partitioning of 75/25 for the training and testing data was adopted, respectively. The model performance was measured based on the mean square error (MSE) and coefficient of correlation between the actual and predicted ARA. Equation (5) represents the root mean square error. The correlation between anticipated/predicted and actual/observed ARA was estimated using Equation (6).  
\[F^{1}(r)=2/\left(1+e^{-2r}\right)-1 \tag{3}\]  
where \(F^{1}\) is a tangent sigmoid equivalent transfer function; \(r\) is the independent variable, while \(e\) denotes the natural log constant (2.718281).  
\[y_{p}(u)=\frac{(y_{max}-y_{min})(u-u_{min})}{(u_{max}-u_{min})}+y_{min} \tag{4}\]  
where \(u\) denotes a set of finite real numbers between \([-1,1]\), while the minimum and maximum values of the original target dataset is represented by \(y_{min}\) and \(y_{max}\), respectively.  
\[RMSE=\sqrt{MSE}=\sqrt{\frac{\sum_{i}^{n_{t}}\left(y_{ai}-y_{p}(u_{i})\right)^{ 2}}{n_{t}-n_{p}}} \tag{5}\]  
\[R^{2}=1-\frac{\sum_{i}^{n_{t}}\left(y_{ai}-y_{p}(u_{i})\right)^{2}}{\sum_{i}^ {n_{t}}\left(y_{ai}-\overline{y_{a}}\right)^{2}} \tag{6}\]  
where \(RMSE\): root mean square error, \(y_{ai}\): actual observed ARAs, \(y_{p}(u_{i})\): modeled or predicted ARAs, \(n_{t}\): total number of observed/actual ARAs, \(n_{p}\): number of model parameters, \(\overline{y_{a}}\): mean of observed/actual ARAs.