# Fault Prediction and Reconfiguration Optimization in Smart Grids: AI-Driven Approach
## 6 Results and Discussion
### Random Forest  
The confusion matrix provided some metrics that were essential to evaluate the performance of the RF model. Firstly, if we only focus on _Accuracy_, the results seemed quite good for the five tests conducted with different dimensionality reduction techniques applied during the RF model training. However, when analyzing the _Precision_ and _Recall_ metrics, notable differences were observed. For example, PCA application with two components  
\begin{table} \begin{tabular}{c c c c c c c c} \hline \hline  & & \multicolumn{3}{c}{_Corfusion Matrix_} & \multicolumn{3}{c}{_K-Fold Cross-Validation_} \\ \cline{3-8}  & & _Accuracy_ & _Precision_ & _Recall_ & _F1 Score_ & _Accuracy_ & _Standard Deviation(\(\boldsymbol{\boldsymbol{\boldsymbol{\boldsymbol{\boldsymbol{\boldsymbol{\boldsymbol{\boldsymbol{ \boldsymbol{\boldsymbol{\boldsymbol{\boldsymbol{\boldsymbol{\boldsymbol{\boldsymbol{ \boldsymbol{\boldsymbol{ \boldsymbol{ }}}}}}}}}}}}}\)) Loss_ \\ \hline \multirow{8}{*}{_Random Forest_ _[_125 estimators_]_} & _None Applied_ & 99.29 & 94.40 & 74.27 & 83.16 & 99.30 & 0.02 \\ \cline{2-8}  & _RFECV_ & 99.44 & 94.28 & 81.05 & 87.17 & 99.47 & 0.02 \\ \cline{2-8}  & _lbest (n = 5)_ & 97.79 & 65.97 & 12.55 & 21.08 & 97.80 & 0.02 \\ \cline{2-8}  & _lbest (n = 8)_ & 97.74 & 53.95 & 27.37 & 36.32 & 97.79 & 0.01 \\ \cline{2-8}  & _PCA (n = 2)_ & 97.55 & 12.52 & 00.67 & 01.27 & 97.35 & 0.01 \\ \cline{2-8}  & _PCA (n = 4)_ & 98.06 & 81.66 & 22.60 & 35.41 & 98.04 & 0.00 \\ \hline \multirow{8}{*}{_SVM_ _[_\(C=1\), kernel = rtf_]_} & _None Applied_ & 97.23 & 89.32 & 06.95 & 12.83 & 97.79 & 0.01 \\ \cline{2-8}  & _lbest (n = 5)_ & 97.11 & 65.25 & 12.29 & 20.73 & 97.80 & 0.01 \\ \cline{1-1} \cline{2-8}  & _lbest (n = 8)_ & 97.05 & 71.19 & 09.30 & 16.46 & 97.79 & 0.01 \\ \cline{1-1} \cline{2-8}  & _PCA (n = 2)_ & 97.61 & - & 0 & - & 97.76 & 0.00 \\ \cline{1-1} \cline{2-8}  & _PCA (n = 4)_ & 97.61 & - & 0 & - & 97.76 & 0.00 \\ \hline \multirow{2}{*}{_ANN_ _[_15, 5_]_, _relu, sggl_} & _None_ & 97.84 & 69.03 & 14.98 & 24.66 & 97.83 & \(\boldsymbol{\boldsymbol{\boldsymbol{\boldsymbol{\boldsymbol{\boldsymbol{ \boldsymbol{\boldsymbol{\boldsymbol{\boldsymbol{\boldsymbol{\boldsymbol{\boldsymbol{ \boldsymbol{ }}}}}}}}}}}}\) \\ \cline{1-1} \cline{2-8}  & _lbest (n = 5)_ & 97.84 & 72.17 & 13.49 & 22.74 & 97.85 & \(\boldsymbol{\boldsymbol{\boldsymbol{\boldsymbol{\boldsymbol{\boldsymbol{ \boldsymbol{\boldsymbol{\boldsymbol{\boldsymbol{\boldsymbol{\boldsymbol{\boldsymbol{ \boldsymbol{\boldsymbol{ \boldsymbol{ \boldsymbolboldsymbol{ \boldsymbolboldsymbolboldsymbol }}}}}}}}}}}}}\) \\ \hline \hline \end{tabular}  Note: \(\boldsymbol{\boldsymbol{\boldsymbol{\boldsymbol{\boldsymbol{\boldsymbol{\boldsymbol{ \boldsymbol{\boldsymbol{\boldsymbol{\boldsymbol{\boldsymbol{\boldsymbol{\boldsymbol{\boldsymbol{\boldsymbol{ \boldsymbol{\boldsymbol{ \boldsymbol{ \boldsymbol{ \boldsymbol{ }}}}}}}}}}}}}}}\)_._ _We denote the confusion matrix provided some metrics that were essential to evaluate the performance of the RF model. Firstly, if we only focus on _Accuracy_, the results seemed quite good for the five tests conducted with different dimensionality reduction techniques applied during the RF model training. However, when analyzing the _Precision_ and _Recall_ metrics, notable differences were observed. For example, PCA application with two components  
Figure 19: Evolution of the loss function value for the ANN from _Keras_. obtained a result with a good _Accuracy_ value (97.55%), but the _Precision_ was poor (12.52%), which indicated that the percentage of detected errors out of the total errors in the dataset was extremely low (0.67%). Therefore, the _F1 Score_ was also significantly low (1.27%), as it is a metric that combines the values of _Precision_ and _Recall_. Accordingly, by analyzing all the metrics provided by the confusion matrix, it was determined that the dimensionality reduction technique that worked best in training the RF was the RFECV.