## 4 Random Forests Theory
### Improved Random Forest Algorithm
Finally, 880 sets of validation dataset, \(Vd\), were selected from the \(DP\) to calculate the performance index. The comparison results are as shown in Table 7. The simulation results show that the proposed algorithm has the highest accuracy (96.25%) and recall (97.73%). This shows that the proposed method can check all fault types well and avoid fault miss detection. However, the ensemble ELM has the highest (96.15%), which reflects that the algorithm has the best performance in avoiding false positives. The offline test time of the proposed method is about 0.2837 s reflecting the proposed method has less computation time while achieving the same diagnosis performance. \begin{table}
\begin{tabular}{c c c c} \hline \hline
**Diagnosis Method** & **Accuracy** & **Precision** & **Recall** \\ \hline BN & 95.79\% & 96.10\% & 95.45\% \\ SVM & 96.33\% & 96.09\% & 96.59\% \\ RFs & 99.64\% & 99.74\% & 99.55\% \\ Ensemble ELM & 99.76\% & 99.74\% & 99.75\% \\ The proposed method & 99.55\% & 99.33\% & 99.77\% \\ \hline \hline \end{tabular}
\end{table} 
Table 6: The 10-fold cross-validation results. \begin{table}
\begin{tabular}{c c c c c} \hline \hline
**Diagnosis Method** & **Accuracy** & **Precision** & **Recall** & **Offline Test Time** \\ \hline BN & 81.36\% & 85.45\% & 78.99\% & 1.1527 s \\ SVM & 84.93\% & 91.4\% & 77.27\% & 3.0729 s \\ RFs & 88.98\% & 90.15\% & 89.58\% & 0.1374 s \\ Ensemble ELM & 94.55\% & 96.15\% & 93.75\% & 1.9273 s \\ The proposed method & 96.25\% & 94.92\% & 97.73\% & 0.2837 s \\ \hline \hline \end{tabular}
\end{table} 
Table 7: Validation and comparison with other methods. \begin{table}
\begin{tabular}{c c c c c c} \hline \hline
**Hyperparameters** & **Results** & \
\begin{tabular}{c} **Decision** \\ **Tree Label** \\ \end{tabular} & **Weight** &
\begin{tabular}{c} **Decision** \\ **Tree Label** \\ \end{tabular} & **Weight** \\ \hline \(X_{OS}\) & 0.2693 & 100 & 0.6237 & 500 & 0.2678 \\ \(X_{TP}\) & 0.0151 & 200 & 0.9764 & 600 & 0.7884 \\ \(K\) & 1246 & 300 & 0.1366 & 700 & 0.8256 \\ \(M\) & 0.0217 & 400 & 0.8247 & 800 & 0.9314 \\ \hline \hline \end{tabular}
\end{table} 
Table 5: The optimization model results and some decision tree weights of the proposed method. Due to the training data being mainly from ideal simulation system, the performance of BN, SVM, and RFs fault diagnosis is poor when applied to the real system with disturbance factors. However, the proposed methods and the proposed algorithm improve the adaptability of the diagnostic model by modifying the weights of the model through disturbed data. Therefore, the above results show that the proposed method has good generalization performance

Besides, in order to simulated random disturbance, we add Gaussian white noise with different variances, \(M\), to the validation dataset, \(Vd\), to verify the robustness of the proposed method as shown in Figure 3. With the increase in \(M\), the fault diagnosis accuracy of other methods decreases. Especially when M = 6%, the fault diagnosis accuracy of these fault diagnosis methods is lower than 75.12% due to signal disturbance. As a comparison, the fault diagnosis accuracy of the proposed method is above 92.16% when M < 6%. It shows that the proposed method has excellent robustness. ### Experimental Verification

To verify the feasibility of the method, an online fault diagnosis experiment is carried out on the three-phase PWM inverter. The three-phase PWM inverter online fault diagnosis system is shown in Figure 4. The fault diagnosis system consists of an IPC and data caching system realized by FPGA, in which the underlying controller is used for open-circuit fault monitoring, the IPC can be replaced by an ARM chip, and the proposed RFs can run on the ARM chip. The sampling clock of the closed-loop control system is 100 kHz, and the sampling frequency is 20 kHz. At the same time, the current signal is resampled with a clock of 10 kHz and a resampling frequency of 10 kHz. Therefore, it only sends 200 points to the IPC per cycle (20 ms) to reduce the pressure of computational burden.