## 5 Prediction Process  
In the previous sections, the most relevant variables were identified. To understand which variables have the most meaning in predicting the incidents and which ones are explanatory, further analysis was conducted. Two different datasets with different variables were considered, as follows. In the first dataset (Dataset 1), the variables considered were: incident type--the one we intend to predict, i.e., the dependent variable--precipitation, number of vehicles involved, the number of people involved, and the average age of the buildings, as represented in Table 2. As some of these variables are only known after/during the occurrence of the incident, we created a more explanatory dataset (Dataset 2), with the dataset 1 variables present. This new dataset is composed of the following variables: number of buildings by structure, number of buildings by number of floors, buildings built by decade, state of preservation, average age of the buildings, number of social stores present in that area, number of people by zone, month of the occurrence, temperature of the day, and city zone. In Dataset 2, there are more explanatory variables, where it is possible to reach several conclusions, like the ones presented in Section 4. The dependent variable (incident type) takes four possible values (four types of an incident), as follows:  
* Fire (building fires);
* Infrastructure (floods and falls);
* Industrial-technological (gas leaks and suspicious situations);
* Accident (with equipment or with elevators). As the problem we are dealing with is a classification one and the dependent variable is discrete, classification algorithms were used: Logistic Regression, KNN, Support Vector Machine (SVM), Naive Bayes, Decision Tree, and Random Forest algorithms. Before implementing any algorithm, we divided the dataset in two parts: the first part, with 80% of the data, was used to train the algorithms; the second part, with 20% of the data, was used to evaluate the predicted results. To identify the number of neighbors of KNN that assure that this algorithm achieves the maximum performance, we conducted a simulation for the number of neighbors with twenty iterations. In every iteration, we calculated the accuracy value and saved it. Furthermore, these values were used to build a plot and identify the maximum accuracy value, i.e., the best result achieved. The output of this function can be seen in Figure 12, which shows that the algorithm achieves its best accuracy performance with a k = 14. The obtained results show that, for a certain point in space, it will be classified according to the 14 closest neighbors, based on the Euclidean distance. For SVM, the random state parameter that rearranges the data for probabilistic estimations was added. As the dependent variable has four prediction classes, the SVM's performance accuracy was limited. The Random Forest algorithm combines the output of multiple (randomly created) Decision Trees to generate the final output. In the random forest, we made several attempts, and the best result obtained was for 900 trees (default is 100), where, again, we used the Random State, as shown in Figure 13 for Dataset 1. The decision tree/random forest showed better accuracy than the SVM. \begin{table}
\begin{tabular}{c c c c c} \hline \hline  & **Number Vehicles** & \
\begin{tabular}{c} **Number of** \\ **Human Resources** \\ \end{tabular} &
\begin{tabular}{c} **Weather** \\ **Condition-Precipitation** \\ \end{tabular} & **Building Age** \\ \hline Industrial–tech. & ++ & ++ & + & ++ \\ Infrastructure & ++ & + & ++ & ++ \\ Fire & ++ & ++ & + & + \\ Accidents & + & + & + & + \\ \hline \hline \end{tabular}
\end{table} 
Table 2: Incident type versus variable importance from the data analytics performed, where ++ means higher intensity of occurrences ++ medium intensity of occurrences and + lower intensity of occurrences. For Dataset 1, the prediction algorithm showing the best prediction performance was Random Forest, achieving 62.74% accuracy.