## 5 Data Preprocessing
### Evaluation of Classifiers  
The different models are evaluated, for which a new data matrix called Test Matrix (see Equation (14)) is classified. This evaluation allows one to verify whether the classification is optimal when using the different models. The Test Matrix contains 7994 records, where 3997 have the label 0 = NO FRAUD and the rest the label 1 = FRAUD. Once the information is validated and anomalies were removed, the data are normalized by using Equation (15); then, classification is performed by using the trained models. The results of the classification are represented through the confusion matrix shown in Table 13. It also displays the evaluation results with Accuracy (Acc) and F1 Score. It is noted that the best classifier is CGB, with similar results for LGB, XGB, ANN, DT, and RF. In Figures 12 and 13, the results of the evaluation and cross-validation are displayed by using the metrics accuracy (Acc) and F1 score, respectively. It is noted that the classifier with the best performance is CGB, while the classifier with the lowest productivity is NB. Similarly, the table shows that the results obtained in the evaluation are lower than those obtained from the cross-validation. \begin{table}
\begin{tabular}{l c c c c c c} \hline \hline
**Model** & **TP** & **FP** & **FN** & **TN** & **Acc** & **F1** \\ \hline K-NN & 3588 & 409 & 2231 & 1766 & 0.67 & 0.731 \\ SVM & 3639 & 358 & 1521 & 2476 & 0.765 & 0.795 \\ DT & 3658 & 339 & 919 & 3078 & 0.843 & 0.853 \\ RF & 3666 & 331 & 1139 & 2858 & 0.816 & 0.833 \\ ANN & 3653 & 344 & 963 & 3034 & 0.837 & 0.848 \\ CGB & 3689 & 308 & 739 & 3258 & 0.869 & 0.876 \\ LGB & 3673 & 324 & 727 & 3270 & 0.869 & 0.875 \\ XGB & 3668 & 329 & 749 & 3248 & 0.865 & 0.872 \\ RL & 3468 & 528 & 1956 & 2042 & 0.689 & 0.736 \\ NB & 46 & 3951 & 17 & 3980 & 0.504 & 0.023 \\ \hline \hline \end{tabular}
\end{table} 
Table 13: Evaluation results. \begin{table}
\begin{tabular}{c c c c c c} \hline \hline
**Model** & **K-NN** & **SVM** & **DT** & **RF** & **ANN** \\ \hline Time [s] & 66.1 & 5010.4 & 14.04 & 647.8 & 1447.8 \\ \hline
**Model** & **LGB** & **CGB** & **XGB** & **RL** & **NB** \\ \hline Tiempo [s] & 303.3 & 1536.2 & 405.6 & 600.9 & 489.3 \\ \hline \hline \end{tabular}
\end{table} 
Table 12: Cross-validation execution time [s]. The Test Matrix, consisting of approximately 7994 samples (30% of the Clean Matrix), is larger than the number of samples developed during the cross-validation stage. This is why lower values are obtained in the calculated metrics. This indicates that the training models classify with results similar to any data matrix. Proposed Methodology for Distribution System Operator  
The proposed methodology for generating lists of measurement systems that determine probable causes of NTLs consists of five stages, which are described below. Stage 1: Planning: The ODS staff meet to establish review criteria for short-, medium-, and long-term periods:  
* **Short term:** Generate review lists where consumption is critical, such as high consumption, because damage to the meter or tampering can cause significant losses for the distribution company. * **Medium term:** Conduct reviews based on geographical stratification, meaning the lists for inspection should first include those with high consumption, followed by those with lower consumption. * **Long term:** Review all customers who have had zero kWh/month consumption for more than twelve consecutive months or whose average annual consumption is less than or equal to 15 kWh. Stage 2: Data preparation: The data are processed for subsequent classification:  
Figure 12: Accuracy—test and validation. Figure 13: F1—test and validation. * Clean erroneous and inconsistent data. * Remove measurement systems that have already been inspected on site within the past 12 months. * Calculate the variables related to consumption as indicated. * Normalize the data by using Equation (15). Stage 3: Data classification: Employ classification methods.