# Predicting Road Traffic Accidents--Artificial Neural Network Approach
## 2 Methodology
### Statistical Analysis  
#### 2.1.1 ANN Modeling  
A multi-layer perceptron (MLP) structural models, consisting of three layers (input, hidden, and output) were implemented for modelling the artificial neural network models (ANN) for prognostication the number of traffic accidents, based on the road conditions. In the first ANN model (ANN1), the length of the road section, road section type (level--1, rolling--2 and mountainous--3), curvatures in the road (no significant bends--1, severe--2, serpentines--3), road width (>6 m, 5-6 m and <5 m) and AADT were used for prediction of the number of traffic accidents in state roads (1 st class), and state roads (2 nd class), in the Republic of Srpska and two-way roads in the Republic of Serbia. The ANN2 model was used for the prediction of the number of traffic accidents, and also the consequences of traffic accidents including the number of: fatalities--F, disabling injury--DI, evident injury--EI, and property damage only -PDO in the highways of the Republic of Serbia, according to the length of the road section, road section type (plain--1, hill--2 and mountain--3), speed limit (130 km/h, 100-130 km/h and <100 km/h) and AADT. The length of the road section, road section type, curves in the road, road width and speed limit were used as categorical variables. The number of crashes, and also F, DI, EI and PDO were employed as numerical variables for the ANN1 and ANN2 modelling. Considering the literature references, the ANN models were widely accepted as comprehensively suitable for the solution of nonlinear problems [39; 40; 41]. Prior to the ANN model building, input and output variables were standardized to augment the exactness of ANN model's results. Throughout the iterative process, input data were consistently submitted to the ANN network [42; 43]. The Broyden-Fletcher-Goldfarb-Shanno (BFGS) algorithm was employed as an iterative tool for solving unconstrained nonlinear optimization in the course of ANN model building. Figure 4 shows the flowchart of the research conducted with the aim of determining the most appropriate ANN model in terms of predictive ability, but also in terms of the error rate of each model. The present study is characterized by the comparative evaluation of different artificial neural networks (ANN), with the aim of predicting the number of traffic accidents, as well as the severity of their consequences, including fatalities, injuries and property damage through using objective factors that can be easily determined, such as road length, terrain type, road width, average daily traffic volume, and speed limit. Figure 3: Main roads of the Republic of Srpska. The collected data for ANN modelling was randomly partitioned into training, cross-validation, and testing data (with shares of 70%, 15%, and 15% of collected data, respectively). A series of 100,000 different MLP configurations were studied, through the training cycle, by changing the number of neurons in hidden layer (between 5 and 10) applying random preliminary values of weights and biases for the ANN model, and testing different activation functions for hidden and the output layer (such as hyperbolic tangent, logistic sigmoidal, exponential or identity). Using identity function the activation level from the input is passed on directly as the output of the neurons. Logistic uses the logistic sigmoid S-shaped function, with output in the range 0 to +1. The hyperbolic tangent function (tanh) is a symmetric S-shaped (sigmoid) function, whose output lies in the range \(-1\) to +1. It often performs better than the logistic sigmoid function due to its symmetry. Exponential uses the negative exponential activation function. The optimization setup included the minimization of the square error. It is assumed that the successful training was reached when learning and cross-validation curves approached zero. The coefficients involved with the hidden layer (weights and biases) were split up in matrices \(W_{1}\) and \(B_{1}\).