# Defect Prediction for Capacitive Equipment in Power System
## 4 Experiments
### Data Collection and Preprocessing
#### 4.1.2 Feature Encoding  
Since the machine learning algorithm we employ exclusively deals with numerical data, it becomes crucial to perform feature encoding on each variable. There are two common encoding methods: one-hot encoding [37] and label encoding [38]. Label encoding preserves the original feature dimensions, conserves space, and minimizes information loss. It is noteworthy that label encoding may result in significant information loss if the sample order is altered. In contrast, one-hot encoding effectively handles categorical data and expands the feature space. For our study, we implement one-hot encoding and compare it with WOE encoding.  
The procedure of WOE encoding is depicted in Figure 2. Initially, the cleaned dataset is read and divided into three equal parts, labeled as dataset D1, D2, and D3. The defect prediction model follows a binary classification approach, employing the output variable  
\begin{table}
\begin{tabular}{c c c c c c} \hline
**Power Supply** & **Voltage Level** & **Defect Level** & **Defect Type** & **Equipment Type** & **Manufacturer** \\
**Bureau** & & & & & \\ \hline
502 & 10,000 & General & Bird nest & Overhead conductor & Jinbei Electric Co., Ltd. \\
502 & 400 & Critical & Insufficient safe & Low-voltage overhead & Kunming Cable Group \\  & & & & & \\  & & & & & \\
502 & 35,000 & Urgent & Low insulation & Isolating switch & Yunnan Yunkai \\  & & & & & Electric Co., Ltd. \\
502 & 110,000 & General & Visible gas in the Buchholz relay & Oil-filled transformer & Jiangsu Huapeng \\  & & & & & \\ \hline \end{tabular}
\end{table}
Table 2: Examples of original capacitive equipment defect data.  
\begin{table}
\begin{tabular}{c c c c c} \hline
**Level** & **Urgent** & **Critical** & **General** & **Others** \\ \hline Size & 3275 & 1496 & 5894 & 1050 \\ \hline \end{tabular}
\end{table}
Table 1: Sample size of different defect levels.  
'whether there is a defect' as the target variable to compute WOE using Equation (1). The defect level prediction model adopts a four-class classification model. However, the direct computation of WOE values for the four defect severity levels did not yield satisfactory results. Therefore, we transformed the four-class classification into binary classification for each defect level by establishing four '1 vs. rest' cases for WOE computation as follows: Four target variables were established, namely 'level_1', 'level_2', 'level_3', and 'level_4'. For 'level_1', a value of '1' was assigned to the defect level 'urgent', while the other three levels were assigned a value of '0' to calculate a WOE value for 'level_1'. This procedure was repeated for the other defect levels. Consequently, the original feature yielded four WOE values for the defect level prediction model.  
WOE computation was executed using a three-fold cross-assignment approach to mitigate overfitting, as shown in Figure 3. Specifically, the WOE values for the data points in dataset D3 were computed based on datasets D1 and D2. Likewise, the WOE values for D1 were determined based on D2 and D3, and so forth. Examples of WOE values for defect detection and defect level prediction are presented in Tables 3 and 4, respectively. Furthermore, Table 3 also provides some examples of one-hot encoding.  
Figure 3: Three-fold cross-assignment.  
Figure 2: Flowchart of WOE feature encoding.