# A Fast Parallel Random Forest Algorithm Based on Spark
## 5 Experiments
### Evaluation of Algorithm Performance  
Four evaluation indicators, _Accuracy, Precision_, _Recall_, and _F1-value_, are used to measure the classification performance of the algorithm. The calculation formula of the evaluation indicators is as follows:  
\[Accuracy=\frac{TP+TN}{TP+TN+FP+FN} \tag{7}\]  
\[Precision=\frac{TP}{TP+FP} \tag{8}\]  
\[Recall=\frac{TP}{TP+FN} \tag{9}\] \begin{table}
\begin{tabular}{c c c c} \hline \hline
**Data Set** & **Instances** & **Features** & **Class** \\ \hline Glass & 214 & 9 & 7 \\ Wine & 178 & 13 & 3 \\ Ionosphere & 351 & 33 & 2 \\ Optical & 3823 & 64 & 10 \\ Image & 2310 & 19 & 7 \\ Letter & 20,000 & 16 & 26 \\ Adult & 48,842 & 14 & 2 \\ HT\_senor & 919,438 & 11 & 100 \\ WinniPeg & 325,834 & 175 & 7 \\ Swarm & 24,017 & 2400 & 2 \\ SUSY & 5,000,000 & 18 & 2 \\ \hline \hline \end{tabular}
\end{table} 
Table 3: Data set information. \[F1=\frac{2}{1/Precision+1/Recall} \tag{10}\]  
where _TP_ and _FN_ are the numbers of correctly and incorrectly classified compounds of the actual positive class, respectively. Similarly, _TN_ and _FP_ denote the number of correctly and incorrectly classified compounds of the actual negative class. This section used seven small data sets from UCI, Glass, Wine, Letter, Ionosphere, Optical, Image, and Adult to compare the accuracy and running time with RF and MGARF [26]. All data were divided into 70% for training and 30% for testing, and the number of trees was set to 200. The selection rate of the best individual and the seed selection rate parameters of MGARF was set to 0.8, and other parameters were set to their default values according to the literature [26]. The experimental results are shown in Table 4.  
The best performance is shown in bold.As shown in Table 4, the algorithm proposed in this paper has achieved the best classification results on the four data sets of Wine, Glass, Letter, and Adult. Furthermore, compared with the traditional Random Forest (RF) algorithm, the proposed algorithm achieved an average 2.01% higher classification accuracy, indicating that the classification accuracy is improved by correcting the redundant relationships among features. Additionally, the run time of the proposed algorithm is relatively faster than that of the MGARF algorithm, which indicates that the approximate equal-frequency binning method reduces the number of candidate split points and sacrifices a certain degree of accuracy in exchange for improved efficiency. These running times on small to medium data sets are shown in Figure 5. Our algorithm has slightly longer running times for some small data sets compared to RF because of the new Gini coefficient definition. However, as the size of the data set increases, the advantage of the proposed algorithm in terms of running time becomes apparent. For some medium data sets, such as Ionosphere, Letter, and Adult, the proposed algorithm has fewer running times and a 5.03% reduction in average running time compared to RF. Furthermore, the traditional random forest algorithm based on single machine computation is difficult to handle large-scale data within an acceptable time range. It tends to experience memory overflow during the execution, resulting in program termination. Instead, the proposed algorithm is effective for parallel computing in a distributed environment. In addition, the algorithm in this paper is also compared with the current popular classification algorithms K-nearest neighbor (KNN), support vector machines (SVM) [27], and naive bayes (NB) [28]. In the experiment, these three classification algorithms are implemented using the sklearn machine learning library, and the parameters of these algorithms are set to default values. The four indicators of _Accuracy_, _Precision_, _Recall_, and _F1-value_ are mainly compared and analyzed. The experimental results are five-fold cross-validation. For the repeatability of the experiment, the random seed random_state is set to a fixed value of 42 in the algorithm, and the experimental results are shown in Table 5.