# Drilling Condition Identification Method for Imbalanced Datasets
## 2 Feature Selection Algorithm Based on Weighted Symmetric Uncertainty
### Weighted Symmetric Uncertainty  
Weighted symmetric uncertainty is an extended form of symmetric uncertainty. Symmetric uncertainty is essentially a measure based on information entropy, used to quantify the nonlinear relationship between two variables [25]. In the feature selection process, symmetric uncertainty is often used to assess the correlation between features and class labels, thereby selecting features that are more strongly correlated with the target class [26]. Weighted symmetric uncertainty, on this basis, introduces a mechanism for adjusting class weights. By assigning weights to different classes, it enhances the adaptability to class-imbalanced data distributions [27]. In this context, the drilling condition categories are denoted by \(S\), the total sample size is denoted by \(N\), and the weight for each class is defined as follows:  
\[w_{i}=1-\frac{n_{i}}{N} \tag{1}\]  
where \(n_{i}\) is the sample size of class \(s_{i}\), and \(w_{i}\) is the weight assigned to class \(s_{i}\). The weighted entropy of feature \(X\) is defined as follows:  
\[H_{w}(X)=-\sum_{i}\sum_{j}w_{i}P\big{(}s_{i},x_{j}\big{)}\log_{2}\big{(}P\big{(} x_{j}\big{)}\big{)} \tag{2}\]  
where \(P\big{(}s_{i},x_{j}\big{)}\) is the joint probability of class \(S\) and feature \(X\), \(P\big{(}x_{j}\big{)}\) is the prior probability of feature \(X\). The conditional entropy of feature \(X\) with respect to category \(S\) is defined as follows:  
\[H_{w}(S|X)=-\sum_{j}P\big{(}x_{j}\big{)}\sum_{i}w_{i}P\big{(}s_{i}|x_{j}\big{)} \log_{2}\big{(}P\big{(}s_{i}|x_{j}\big{)}\big{)} \tag{3}\]  
where \(P\big{(}s_{i}|x_{j}\big{)}\) is the posterior probability of class \(S\) given that feature \(X\) has occurred. Given the weighted entropy of feature \(X\) and class \(S\), as well as the conditional entropy, the formula for the weighted information gain is as follows:  
\[\mathrm{IG}_{w}(S|X)=H_{w}(S)-H_{w}(S|X) \tag{4}\]  
where \(H_{w}(S)\) represents the weighted entropy of class \(S\), and \(H_{w}(S)\) denotes the weighted conditional entropy of feature \(X\) with respect to class \(S\). The weighted information gain is defined as the difference between these two terms. Finally, the weighted symmetric uncertainty between feature \(X\) and class \(S\) is defined as follows:  
\[SU_{w}(S,X)=2\bigg{[}\frac{\mathrm{IG}_{w}(S|X)}{H_{w}(S)+H_{w}(X)}\bigg{]} \tag{5}\]  
where \(\mathrm{IG}_{w}(S|X)\) represents the weighted information gain of class \(S\) given feature \(X\), \(H_{w}(S)\) is the weighted entropy of class \(S\), and \(H_{w}(X)\) is the weighted entropy of feature \(X\). Whenthe value of \(SU_{w}(S,X)\) is 1, it indicates that feature \(X\) and class \(S\) are perfectly correlated. When the value of \(SU_{w}(S,X)\) is 0, it indicates that \(X\) and \(S\) are independent of each other. In calculating the weighted uncertainty between feature \(X\) and class \(S\), different weights are assigned to each class based on their proportions. The minority class is given a higher weight, which means that features that are more beneficial for distinguishing the minority class will receive a higher correlation score and are more likely to be retained in the feature selection process. The weighted symmetric uncertainty between each feature \(x_{j}\) and each class \(s_{i}\) is calculated, resulting in a matrix \(K\). \[K= \begin{bmatrix}SU_{w}(x_{1},s_{1})&SU_{w}(x_{2},s_{1})&\ldots&SU_{w}(x_{j},s _{1})\\ SU_{w}(x_{1},s_{2})&SU_{w}(x_{2},s_{2})&\ldots&SU_{w}(x_{j},s_{2})\\ \vdots&\vdots&\ddots&\vdots\\ SU_{w}(x_{1},s_{i})&SU_{w}(x_{2},s_{i})&\ldots&SU_{w}(x_{j},s_{i})\end{bmatrix}  \tag{6}\]  
For each row in the matrix, which represents the weighted symmetric uncertainty between different features and class \(s_{i}\), perform a descending sort. For each class \(s_{i}\), select the top \(t\) features with the highest weighted symmetric uncertainty values, forming the candidate feature subset \(Q_{i}\) for each class.