Feasibility of Stochastic Models for Evaluation of Potential Factors for Safety: A Case Study in Southern Italy

: There is no deﬁnite conclusion about what the main variables that play a fundamental role in road safety are. Therefore, the identiﬁcation of signiﬁcant factors in road accidents has been a primary concern of the transportation safety research community for many years. Every accident is inﬂuenced by multiple variables that, in a given time interval, concur to cause a crash scenario. Information coming from crash reports is very useful in tra ﬃ c safety research, and several reported crash variables can be analyzed with modern statistical methods to establish whether a classiﬁcation or clustering of di ﬀ erent crash variables is possible. Hence, this study aims to use stochastic techniques for evaluating the role of some variables in accidents with a clustering analysis. The variables that are considered in this paper are light conditions, weekday, average speed, annual average daily tra ﬃ c, number of vehicles, and type of accident. For this purpose, a combination of particle swarm optimization (PSO) and the genetic algorithm (GA) with the k-means algorithm was used as the machine-learning technique to cluster and evaluate road safety data. According to a multiscale approach, based on a set of data from two years of crash records collected from rural and urban roads in the province of Cosenza, 154 accident cases were accurately investigated and selected for three categories of accident places, including straight, intersection, and other, in each urban and rural network. PSO had a superior performance, with 0.87% accuracy on urban and rural roads in comparison with GA, although the results of GA had an acceptable degree of accuracy. In addition, the results show that, on urban roads, social cost and type of accident had the most and least inﬂuence for all accident places, while, on rural roads, although the social cost was the most notable factor for all accident places, the type of accident had the least e ﬀ ect on the straight sections and curves, and the number of vehicles had the least inﬂuence at intersections.


Introduction
Traffic accidents are in the top 10 major causes of injuries and deaths [1], representing, with the associated economic loss, an important socioeconomic concern. For these reasons, the identification of the significant factors associated with such crashes has become of major interest and a great challenge in transportation safety research. There are many problems related to the inadequacy and difficulty of obtaining data for analysis as well as the limited crash counts. Moreover, another challenge with such studies is that there may potentially be redundant information and correlations among different candidate factors. Consequently, considerable efforts have to be made in the field of accident analysis to address these problems properly and effectively.
Traditionally, in the scientific literature, statistical models based on crash frequency are a common tool for estimating the safety performance functions of many transportation systems. Count regression models are very often applied in road safety studies dealing with the crash-frequency context [2]. Among them there are Poisson or negative binomial (NB) models [3][4][5][6][7] and zero-inflated Poisson or NB models [5,8,9]. These safety models offer, as an advantage, the opportunity to correlate the specific roadway characteristics and expected crash frequencies. On the contrary, their limits are associated with strong parametric modeling assumptions and omitted variable bias, reducing the prediction suitability. In order to overcome the limits of traditional safety models, several researchers introduced heterogeneity models [10][11][12]. Random parameter models belong to this category of models [13][14][15]; in them, model parameters are allowed to vary from site to site, improving statistical inference and the predictive capability of such models [12]. In addition to traditional and heterogeneity safety models, researchers have proposed many nonparametric and artificial intelligence models for the study of crash injury patterns. Artificial intelligence approaches have been proven to be more efficient and effective in the modeling process [16]. These models are data driven and include decision trees (DT) [17][18][19], support vector machine (SVM) [20,21], and random forest (RF) [22]. The SVM has been utilized for the classification of crash injury severity [23,24] and outperforms the popular ordered probit model for the prediction of injury severity and factor impact assessment [23]. Thanks to the big-data era, optimization efficiency has become a primary concern for the analysis procedure. For these reasons, in the scientific literature, there is a need to develop novel algorithms to handle the traffic crash records efficiently.
The main aim of this paper is to propose a hybrid model combining particle swarm optimization (PSO) and genetic algorithm (GA) with k-means to cluster and to evaluate significant factors affecting road safety. The paper is organized as follows. A literature review of the different model categories and approaches is provided in the next section. Section 2 describes the methodological approach and the theoretical fundaments of particle swarm optimization (PSO) and the genetic algorithm (GA). The case study and the data description are provided in Section 3. In Sections 4 and 5, the application of PSO and GA algorithms have been described. Sections 6 and 7 refer to the discussion of results and conclusions.

Methodology
To cluster a set of unpredicted factors for road safety evaluation, two different stochastic techniques were applied: particle swarm optimization (PSO) and genetic algorithm (GA) with k-means. In both cases, as in several data mining applications, the optimization problem considered is the minimization of Euclidean distance among the different groups of factors. The results obtained by applying the two different techniques were compared in terms of the performance and accuracy of the determined solutions. As a final result, the selected factors were used to create a basic road safety pattern with its temporal and spatial property and dimension.

Genetic Algorithm (GA)
In artificial intelligence, the genetic algorithm (GA), an evolutionary algorithm, is a powerful tool in the evaluation of complex systems. It was introduced and developed by John Holland and his colleagues during the two decades from 1960 [25]. GA works based upon a stochastic search technique and GA's performance is inspired by biological evolution. It has been widely applied in various fields of engineering, including computer sciences [26,27], transportation, and geotechniques [28][29][30][31] as well as mathematics [32]. There are three main operators in the process of GA, which include reproduction, crossover, and mutation rules. Generally speaking, at first, in the process of GA, the initial population is randomly generated as a set of number strings (representation of solutions). Then, the goodness and efficiency of each solution is evaluated by the fitness function (objective function), and the best population (solutions) is selected as generators (parents) based upon a reproduction operator to generate new generations (new solutions) based upon the crossover operator. According to the mutation operator, a random change emerges in the next generation, whereby this new generation has higher fitness values in comparison with the old generation. This loop continues and the accuracy of the process is investigated; if it reaches a desired optimization, the loop is stopped [33]. The basic form of the flowchart of GA is shown in Figure 1.
Sustainability 2020, 12, x FOR PEER REVIEW 3 of 21 a reproduction operator to generate new generations (new solutions) based upon the crossover operator. According to the mutation operator, a random change emerges in the next generation, whereby this new generation has higher fitness values in comparison with the old generation. This loop continues and the accuracy of the process is investigated; if it reaches a desired optimization, the loop is stopped [33]. The basic form of the flowchart of GA is shown in Figure 1.

Particle Swarm Optimization (PSO)
In the modern world, most phenomena and problems deal with complex and nonlinear systems; therefore, they cannot be easily solved. Hence, using artificial intelligence techniques is imperative [35][36][37][38][39][40][41]. Metaheuristic algorithms, a branch of artificial intelligence techniques, are the precise scientific tools to solve uncertain systems in a wide range of sciences and industries [42][43][44][45][46][47][48][49]. Particle swarm optimization (PSO) is one of the notable metaheuristic algorithms that is appropriate for dealing with nonlinear relationships and complex problems. Recently, it has been used successfully to solve complex engineering problems determined by many parameters [28,50,51]. PSO was introduced by Kennedy [52,53]. PSO is inspired by swarm intelligence (SI) and the social behavior of birds and fish in finding enough food in a group. In the process of PSO, a set of solutions, which is a set of particles, is randomly generated; in fact, each solution is a particle. This algorithm works in a D-dimensional community or search space and each particle can affect other neighboring particles or the general particles. Each particle has a velocity vector and, for determining the best optimal answer (new position), two factors of personal best position (Pbest) and global best position (Gbest) are considered [54,55]. Figure 2 shows the movement of particles and their new positions, and the updated velocity vector and position are shown in Equations (1) and (2).

Particle Swarm Optimization (PSO)
In the modern world, most phenomena and problems deal with complex and nonlinear systems; therefore, they cannot be easily solved. Hence, using artificial intelligence techniques is imperative [35][36][37][38][39][40][41]. Metaheuristic algorithms, a branch of artificial intelligence techniques, are the precise scientific tools to solve uncertain systems in a wide range of sciences and industries [42][43][44][45][46][47][48][49]. Particle swarm optimization (PSO) is one of the notable metaheuristic algorithms that is appropriate for dealing with nonlinear relationships and complex problems. Recently, it has been used successfully to solve complex engineering problems determined by many parameters [28,50,51]. PSO was introduced by Kennedy [52,53]. PSO is inspired by swarm intelligence (SI) and the social behavior of birds and fish in finding enough food in a group. In the process of PSO, a set of solutions, which is a set of particles, is randomly generated; in fact, each solution is a particle. This algorithm works in a D-dimensional community or search space and each particle can affect other neighboring particles or the general particles. Each particle has a velocity vector and, for determining the best optimal answer (new position), two factors of personal best position (Pbest) and global best position (Gbest) are considered [54,55]. Figure 2 shows the movement of particles and their new positions, and the updated velocity vector and position are shown in Equations (1) and (2).
where i = (1,2,3, . . . ,N) and N is population size (particle). V i (k+1) and V i (k) are the new velocity vector and old velocity vector of the ith particle, respectively. X i (k+1) and X i (k) represent the new position and old position of the ith particle. Furthermore, K = (1,2,3, . . . ) is the number of iterations. w is the inertia weight that is in the interval of 0.4 to 0.9, and it plays a key role in controlling the effect of the old velocity vector on the new velocity vector; r 1 and r 2 are random numbers that are in the interval of 0 and +1. C 1 and C 2 are the acceleration constants that should be evaluated by experts and based upon Equation (3). In fact, C 1 and C 2 are known as the individual learning and social learning factors, respectively [56,57]. Figure 3 shows the movement and modified position of a particle. The particles continue to search for the best position (solution) and, when they find the best position, the algorithm process is stopped. It is worth mentioning that PSO can be applied to solve continuous and discrete problems.
Sustainability 2020, 12, x FOR PEER REVIEW 4 of 21 where i = (1,2,3,..,N) and N is population size (particle). Vi (k+1) and Vi (k) are the new velocity vector and old velocity vector of the ith particle, respectively. Xi (k+1) and Xi (k) represent the new position and old position of the ith particle. Furthermore, K = (1,2,3,…) is the number of iterations. w is the inertia weight that is in the interval of 0.4 to 0.9, and it plays a key role in controlling the effect of the old velocity vector on the new velocity vector; r1 and r2 are random numbers that are in the interval of 0 and +1. C1 and C2 are the acceleration constants that should be evaluated by experts and based upon Equation (3). In fact, C1 and C2 are known as the individual learning and social learning factors, respectively [56,57]. Figure 3 shows the movement and modified position of a particle. The particles continue to search for the best position (solution) and, when they find the best position, the algorithm process is stopped. It is worth mentioning that PSO can be applied to solve continuous and discrete problems.

4
(3) where i = (1,2,3,..,N) and N is population size (particle). Vi (k+1) and Vi (k) are the new velocity vector and old velocity vector of the ith particle, respectively. Xi (k+1) and Xi (k) represent the new position and old position of the ith particle. Furthermore, K = (1,2,3,…) is the number of iterations. w is the inertia weight that is in the interval of 0.4 to 0.9, and it plays a key role in controlling the effect of the old velocity vector on the new velocity vector; r1 and r2 are random numbers that are in the interval of 0 and +1. C1 and C2 are the acceleration constants that should be evaluated by experts and based upon Equation (3). In fact, C1 and C2 are known as the individual learning and social learning factors, respectively [56,57]. Figure 3 shows the movement and modified position of a particle. The particles continue to search for the best position (solution) and, when they find the best position, the algorithm process is stopped. It is worth mentioning that PSO can be applied to solve continuous and discrete problems.

4
(3) Figure 3. Concept of the modification of the movement of a particle by the particle swarm optimization (PSO) algorithm [58].

The Optimization Function and the Correlation Analysis Method
As mentioned before, the fitness function contributes greatly to the determination of the solution. Hence, Lloyd's algorithm (k-means clustering) is considered the fitness function for two metaheuristic algorithms according to the problem statement in this research work. Equation (4) represents Lloyd's algorithm, which is a common and popular clustering algorithm in data mining [59].

The Optimization Function and the Correlation Analysis Method
As mentioned before, the fitness function contributes greatly to the determination of the solution. Hence, Lloyd's algorithm (k-means clustering) is considered the fitness function for two metaheuristic algorithms according to the problem statement in this research work. Equation (4) represents Lloyd's algorithm, which is a common and popular clustering algorithm in data mining [59].
where x i and m j are the data set and center of each cluster, respectively, and j = (1,2,3, . . . ,k) indicates the number of the cluster. Furthermore, d is the Euclidean distance between each member and the center of each cluster. It is worth mentioning that two aims are considered (for the Lloyd's algorithm) the fitness function: these are the distance of the centers of the clusters from each other and also the distance between the members of a cluster, which should become maximization and minimization, respectively. Before modeling, correlation analysis of the data set is imperative because a high correlation between data sets can have a negative impact on the performances and results of clustering algorithms. Hence, although the dataset was considered by experts in this study, a correlation analysis was conducted. Pearson's correlation coefficient, a suitable and common correlation analysis, was used for the evaluation of the data set. Mathematical relations are shown in Equations (5) to (8), in which ρ(r) is known as Pearson's correlation coefficient for two independent parameters (X and Y). SP Dxy is the covariance of X and Y. SS X and SS Y indicate the standard deviation of X and Y, respectively [60][61][62]. It is worth mentioning that the value of ρ(r) is in the interval of −1 and +1, in which the absolute values of the coefficient demonstrate degrees of correlation and the signs only represent a direct (+) and reverse (−) relation between two independent parameters.

Crash, Traffic, and Speed Data
The crash data used in this research have been derived from the large database of Istituto Nazionale di Statistica (ISTAT). Each crash record was obtained from the collaboration of a multiplicity of entities: ISTAT, Automobile Club Italia (ACI), the Ministry of the Interior, the traffic police department, the Carabinieri, the provincial police, the municipal police, the offices of statistics of the provincial capitals, and the statistical offices of some provinces that have signed an agreement with ISTAT. The database contains details on road accidents that were reported by a police authority, occurred in the national territory over a calendar year, and caused injuries to people (death or injury). There is information on crash dynamics and location, on vehicles, and on the individuals involved, but it does not include property damage only (PDO) events in accordance with current Italian legislation. Indeed, Italian legislation defines road accidents as crashes only when they result in at least one injury [63].
In this research, the road accidents that were selected occurred during two years (2017 and 2018) on the main rural and urban roads of the province of Cosenza ( Figure 4). A total of 154 crash events were elaborated, considering 77 accidents on rural roads and 77 on urban roads. In order to analyze and compare homogeneous road accident samples by applying PSO and GA techniques, two samples of 77 crashes for both urban and rural cases were extracted from an accident database. These crashes have been distinguished and grouped by territorial area (urban and rural) and homogeneous geometric elements (intersection, straight, curve, other, etc.). The ISTAT database fields considered in this study are summarized in Table 1.   The fields of the ISTAT database were matched up with ad hoc traffic surveys on the same rural and urban roads considered in order to derive average vehicular speeds and average traffic volumes. The surveys were conducted for one month in October 2019 with the support of Bluetooth radar sensors, which give output not only on traffic volumes but also vehicular speed values. In particular, radar sensors were located on the road sections with observed crashes. From an evaluation of trafficvolume and speed-value statistical trends over a 10-year period, and considering the social, economic, demographic, and travel demand characteristics of the study area, traffic volumes and vehicular speed values were considered invariant over the last five years. An important aspect for  The fields of the ISTAT database were matched up with ad hoc traffic surveys on the same rural and urban roads considered in order to derive average vehicular speeds and average traffic volumes. The surveys were conducted for one month in October 2019 with the support of Bluetooth radar sensors, which give output not only on traffic volumes but also vehicular speed values. In particular, radar sensors were located on the road sections with observed crashes. From an evaluation of traffic-volume and speed-value statistical trends over a 10-year period, and considering the social, economic, demographic, and travel demand characteristics of the study area, traffic volumes and vehicular speed values were considered invariant over the last five years. An important aspect for the present research was the definition of a segment surrounding each count station, where it could be assumed that homogeneous flow and speed conditions were present for the entire length. If the sensor was positioned on a link with homogeneous geometric characteristics greater than 2 miles in length, a circular buffer 2 miles in diameter around the location of the radar sensor (1 mile upstream and downstream) was defined [64]. The geometric homogeneity of a road segment was defined, taking into account the number of lanes, lane and shoulder width, speed limit, median type, and median width.

Correlation Data Analysis
Six unpredicted and effective variables in accidents, including the daylight, weekday, average speed, annual average daily traffic, number of vehicles, and type of accident were considered for urban and rural roads. As described in Section 2.3, during the first step, 77 accident cases for urban and rural roads related to the six mentioned variables were normalized between 0 and 1 and then correlation analyses were conducted.
The results of the correlation analysis for urban and rural roads are shown in Tables 2 and 3. It should be noted that when |ρ| > 0.85 is established, the correlation between two parameters was considered strong and was not appropriate for clustering analysis. According to the results of Tables 3 and 4, the maximum correlation was −0.378 between the average speed and annual average daily traffic in the urban areas; they have a reverse relation with each other. On the other hand, there was the maximum correlation between the number of vehicles and type of accident of 0.396, with a direct relation between the two in rural areas. Hence, it can be concluded that all parameters in this study have a suitable correlation with each other, which is in full agreement with other studies on road safety [63].

Particle Swarm Optimization Modeling for Urban and Rural Area
Before modeling, some control parameters of the PSO algorithm should be determined at the first step. In order to reach a high level of precision in the performance of the algorithm, it is necessary to determine suitable control parameters, which contribute greatly to the increase of the convergence of the algorithm. There are no determined relations; in fact, these parameters were determined based upon trial and error and experts' opinions [65,66]. The personal learning coefficient (C 1 ) and global learning coefficient (C 2 ) were considered equal to 2. The minimum acceptance precision, ε L = 0.00001, and the maximum number of iterations and population size (swarm size) were considered 300 and 50, respectively. It is worth mentioning that these control parameters can be considered the same for urban and rural situations because the number and type of dataset are the same. Then, modeling was carried out by three classes (clusters) in a Matlab software environment. Figure 5 shows the best cost of performance of the model of the PSO algorithm for urban and rural areas.
Sustainability 2020, 12, x FOR PEER REVIEW 8 of 21 and the maximum number of iterations and population size (swarm size) were considered 300 and 50, respectively. It is worth mentioning that these control parameters can be considered the same for urban and rural situations because the number and type of dataset are the same. Then, modeling was carried out by three classes (clusters) in a Matlab software environment. Figure 5 shows the best cost of performance of the model of the PSO algorithm for urban and rural areas. According to Figure 5, the convergence trends of the algorithm for both areas shows that the performance of the algorithm was reliable because, after the 76th and 39th iterations, the convergence trends remained constant until the 300th iteration for urban and rural areas, respectively. Optimization and clustering of accident cases by the PSO algorithm for urban and rural areas are shown in Tables 4 and 5, respectively.
According to the obtained results in Tables 4 and 5, the Euclidean distance of each accident case from each class (cluster) was calculated based upon the six unpredicted and effective variables in accidents and the lowest distance shows which accident case belongs to which class, and the results are shown in the column of the recognized class. For example, the minimum Euclidean distance in the second case in urban areas was 0.05 from the first class, which shows that this accident case belongs to the first class. In rural areas, the 47th accident case with the minimum Euclidean distance of 0.899 from the third class shows that this case belongs to the third class. Then, the results of the column of the recognized class were compared with the column for the actual type of accident place. Ten cases were wrongly recognized from 77 accident cases for both areas. For instance, in urban areas, the minimum Euclidean distance of the 40th case was calculated as 0.021, which belongs to the first class, although this accident case occurred at the intersection in the actual type. In addition, the 70th case should be recognized at the intersection (second class), although, due to the minimum Euclidean distance, it was recognized in the third class. Generally, the accuracy of the algorithm's performance was 0.87% for both urban and rural networks, and it should be noted that clustering of accident cases for both areas by model had an acceptable degree. The impacts of six unpredicted and effective variables on each category of accident places based upon the Euclidean distance are shown in Table  6. According to Figure 5, the convergence trends of the algorithm for both areas shows that the performance of the algorithm was reliable because, after the 76th and 39th iterations, the convergence trends remained constant until the 300th iteration for urban and rural areas, respectively. Optimization and clustering of accident cases by the PSO algorithm for urban and rural areas are shown in Tables 4  and 5, respectively.
According to the obtained results in Tables 4 and 5, the Euclidean distance of each accident case from each class (cluster) was calculated based upon the six unpredicted and effective variables in accidents and the lowest distance shows which accident case belongs to which class, and the results are shown in the column of the recognized class. For example, the minimum Euclidean distance in the second case in urban areas was 0.05 from the first class, which shows that this accident case belongs to the first class. In rural areas, the 47th accident case with the minimum Euclidean distance of 0.899 from the third class shows that this case belongs to the third class. Then, the results of the column of the recognized class were compared with the column for the actual type of accident place. Ten cases were wrongly recognized from 77 accident cases for both areas. For instance, in urban areas, the minimum Euclidean distance of the 40th case was calculated as 0.021, which belongs to the first class, although this accident case occurred at the intersection in the actual type. In addition, the 70th case should be recognized at the intersection (second class), although, due to the minimum Euclidean distance, it was recognized in the third class. Generally, the accuracy of the algorithm's performance was 0.87% for both urban and rural networks, and it should be noted that clustering of accident cases for both areas by model had an acceptable degree. The impacts of six unpredicted and effective variables on each category of accident places based upon the Euclidean distance are shown in Table 6.     According to the obtained results, daylight had the most influence on accident cases on straight roads for urban and rural areas (0 and 0.016, respectively) because, in both of them, daylight had the lowest Euclidean distance from straight in comparison with other effective variables. On the other hand, annual average daily traffic plays a key role in accident cases at intersections in urban areas, with the lowest Euclidean distance of 0.324, while the type of accident was the most important variable of accident cases at the intersection, with the lowest Euclidean distance of 0 among six variables in rural areas. Finally, the type of accident and the day of the week had the most impact on accident cases in the third category of accident places (other) in comparison with other variables with the lowest Euclidean distance of 0 in urban and rural areas.

Genetic Algorithm Modeling for Urban and Rural Areas
As mentioned before, the control parameters of the algorithm play a key role in the faster convergence of the algorithm. Hence, according to experts' experiences and the number of data sets in this study, some of these parameters were selected, namely, the minimum acceptance precision, ε L = 0.00001, population size (PS) = 250, maximum number of iterations = 250, and crossover and mutation rate (MR), which were 0.8 and 0.02, respectively [67,68]. It should be noted that these values are dimensionless. After determining the control parameters, the models were constructed with a pseudocode of GA in a Matlab environment. With regards to the data set and problem statement in this research work, the number of classes was considered to be three (clusters) for the urban and rural areas dataset. The performance of models according to the best cost is demonstrated in Figure 6.
Sustainability 2020, 12, x FOR PEER REVIEW 12 of 21 According to the obtained results, daylight had the most influence on accident cases on straight roads for urban and rural areas (0 and 0.016, respectively) because, in both of them, daylight had the lowest Euclidean distance from straight in comparison with other effective variables. On the other hand, annual average daily traffic plays a key role in accident cases at intersections in urban areas, with the lowest Euclidean distance of 0.324, while the type of accident was the most important variable of accident cases at the intersection, with the lowest Euclidean distance of 0 among six variables in rural areas. Finally, the type of accident and the day of the week had the most impact on accident cases in the third category of accident places (other) in comparison with other variables with the lowest Euclidean distance of 0 in urban and rural areas.

Genetic Algorithm Modeling for Urban and Rural Areas
As mentioned before, the control parameters of the algorithm play a key role in the faster convergence of the algorithm. Hence, according to experts' experiences and the number of data sets in this study, some of these parameters were selected, namely, the minimum acceptance precision, εL = 0.00001, population size (PS) = 250, maximum number of iterations = 250, and crossover and mutation rate (MR), which were 0.8 and 0.02, respectively [67,68]. It should be noted that these values are dimensionless. After determining the control parameters, the models were constructed with a pseudocode of GA in a Matlab environment. With regards to the data set and problem statement in this research work, the number of classes was considered to be three (clusters) for the urban and rural areas dataset. The performance of models according to the best cost is demonstrated in Figure 6. According to Figure 6, the convergence trends achieved the desired precision level and it was fixed from the 94th to the 300th iteration for the urban dataset, and the convergence trend was fixed from the 102nd to the 300th iteration for the rural dataset. Hence, it can be concluded that the convergence trends of the algorithm had acceptable degrees and speed for urban and rural situations. Tables 7 and 8 show the optimization and clustering of accident cases by the GA algorithm for the urban and rural areas, respectively. According to Figure 6, the convergence trends achieved the desired precision level and it was fixed from the 94th to the 300th iteration for the urban dataset, and the convergence trend was fixed from the 102nd to the 300th iteration for the rural dataset. Hence, it can be concluded that the convergence trends of the algorithm had acceptable degrees and speed for urban and rural situations. Tables 7 and 8 show the optimization and clustering of accident cases by the GA algorithm for the urban and rural areas, respectively.    The optimum partitions of three classes (clusters) were calculated for the urban and rural areas dataset, with these values being based upon the Euclidean distance and being dimensionless. For instance, in the first accident case of the urban area, the minimum Euclidean distance was 0.327, which belongs to the first class, and the results were in full agreement with the actual type of accident place. However, for the 37th accident case of the urban area, the minimum of Euclidean distance belonged to the second class, with 0.168 among three classes, so it did not match with the real case. In the rural area, the model could classify the second accident case in the third class, so it did match with the actual type of accident place. In addition, in the 63rd case of a rural area, the minimum Euclidean distance was 0.234 for the second class among the three classes that the model had an error for in this case because it was "straight" in the real case. Generally, the model of the GA algorithm can classify the urban and rural areas dataset with 82% and 81% accuracies, respectively. Table 9 shows the values of the Euclidean distance of each effective variable from the center of each class by GA. The obtained results in Table 9 show that daylight had the most impact for "straight" in the urban and rural areas in comparison with other variables because it had the lowest Euclidean distance equal to zero. The annual average daily traffic and type of accident were the most important variables for the intersection, with 0.326 and 0 in urban and rural areas, respectively. Finally, the type of accident was the most effective factor, with a Euclidean distance of 0.001 for other sections in the urban area, while the number of vehicles contributes greatly for other sections in rural areas in comparison with other variables.

Results and Discussion
As mentioned before, the aim of the present research work is to propose the feasibility of stochastic models for the evaluation of potential factors for safety. Owing to the ambiguity and uncertainty present in the investigative process of road safety, two stochastic techniques have been proposed for clustering and evaluating safety. Using a data mining approach, two models were developed for evaluating potential safety factors, using 77 accident cases in urban and rural areas in Cosenza in southern Italy. A comparison was made between the obtained results of two algorithms' performances, based upon their accuracies, in Figure 7. Consequently, it was found that, although the PSO algorithm provided more accurate clustering in comparison with GA, both stochastic techniques were reliable system modeling techniques for clustering and evaluating potential safety factors. Furthermore, the two stochastic techniques applied to the case study underlined several common issues.
Models of both algorithms recognized that daylight had the most impact on the "straight" in urban and rural areas and that these results were in full agreement with real conditions of the straight place in two areas of Cosenza.
Annual average daily traffic was considered the most important factor for the "intersection" place only in urban areas by models of PSO and GA. However, these models considered that the type of accident was the most effective variable in rural areas.
Furthermore, in comparison to the Euclidean distances of six variables, both algorithms recognized that the type of accident was the most effective variable for "other" in urban areas.
The unique difference between the two approaches is that, in rural areas, the PSO approach considered the weekday as the most important variable for "other", while the number of vehicles was recognized by the GA model. The reason could be that both PSO and GA start from nearby solutions but, then, PSO converges very quickly while GA struggles up to a great number of iterations and then converges to a solution nearer to PSO, but this solution is still not better than the one provided by PSO.
It should be noted that these two models based upon the determined control parameters and obtained results are case-specific and cannot be used directly for evaluating the safety of transportation systems of other cities. In addition, these techniques are not appropriate for the evaluation of incomplete data.

Conclusions
This paper presented two stochastic techniques to cluster and evaluate transportation safety. For this purpose, a combination of PSO and the genetic algorithm (GA) with the k-means algorithm were used as well as six notable unpredicted variables in accidents, including the daylight, weekday, average speed, annual average daily traffic, number of vehicles, and type of accident, which were considered for urban and rural areas in Cosenza in southern Italy. Some 77 cases of accidents for urban and rural areas were selected and all the cases were classified into three classes. The obtained results were validated based upon three types of accident places, including straight, curve, and intersection, in each urban and rural network. Although both algorithms had a suitable capability to Furthermore, the two stochastic techniques applied to the case study underlined several common issues.
Models of both algorithms recognized that daylight had the most impact on the "straight" in urban and rural areas and that these results were in full agreement with real conditions of the straight place in two areas of Cosenza.
Annual average daily traffic was considered the most important factor for the "intersection" place only in urban areas by models of PSO and GA. However, these models considered that the type of accident was the most effective variable in rural areas.
Furthermore, in comparison to the Euclidean distances of six variables, both algorithms recognized that the type of accident was the most effective variable for "other" in urban areas.
The unique difference between the two approaches is that, in rural areas, the PSO approach considered the weekday as the most important variable for "other", while the number of vehicles was recognized by the GA model. The reason could be that both PSO and GA start from nearby solutions but, then, PSO converges very quickly while GA struggles up to a great number of iterations and then converges to a solution nearer to PSO, but this solution is still not better than the one provided by PSO.
It should be noted that these two models based upon the determined control parameters and obtained results are case-specific and cannot be used directly for evaluating the safety of transportation systems of other cities. In addition, these techniques are not appropriate for the evaluation of incomplete data.

Conclusions
This paper presented two stochastic techniques to cluster and evaluate transportation safety. For this purpose, a combination of PSO and the genetic algorithm (GA) with the k-means algorithm were used as well as six notable unpredicted variables in accidents, including the daylight, weekday, average speed, annual average daily traffic, number of vehicles, and type of accident, which were considered for urban and rural areas in Cosenza in southern Italy. Some 77 cases of accidents for urban and rural areas were selected and all the cases were classified into three classes. The obtained results were validated based upon three types of accident places, including straight, curve, and intersection, in each urban and rural network. Although both algorithms had a suitable capability to classify case accidents, the PSO algorithm had a superior performance, with 0.86% and 0.87% accuracies on urban and rural roads, respectively, in comparison with GA. In addition, the obtained results of the PSO algorithm show that daylight was the most important parameter to evaluate safety for the straight section in urban and rural areas. In addition, the annual average daily traffic and type of accident played a key role in the safety of intersections in urban and rural areas, respectively. Finally, the type of accident and weekday had the most impact on safety in other sections of urban and rural areas.
For future research work, it is recommended to investigate the effectiveness of other artificial intelligence techniques to evaluate transportation safety, which is worth studying, and to extend the study to a five-year reporting period. In addition, the evaluation of the effects of geometric issues (inconsistencies) or pavement deterioration on safety analysis can be considered another important factor in rural environments in future works. Furthermore, it will be advisable to evaluate homogeneous road segments without reported crashes and to compare them with the used dataset to better understand the analyzed phenomenon by coupling artificial intelligence (AI) and machine learning (ML) techniques with other classic techniques, such as the naïve Bayesian (NB) algorithm and structural equation models (SEM).