## 3 Materials and Methods
### Description of the WELAD
#### 3.2.1 Stage I: Generate the Ensemble Classifier with Appropriate Diversity  
The purpose of this stage is to generate a set of ensemble classifiers with appropriate accuracy and adequate diversity by manipulating the training dataset with resampling and select features to create diverse learners. Suppose \(D\) features exist in the diversity training dataset; use K-means clustering to form \(M\) clusters, and let \(\mathbf{R}~{}=~{}(\mathbf{r}_{1},\mathbf{r}_{2},\dots,\mathbf{r}_{L})\) represent the resampling ratio of \(L\)  
Figure 3: Implementation diagram of the WELAD.  
Figure 2: Architecture diagram of the weighted ensemble.  
classifiers to \(M\) sample data clusters matrix, where \(r_{i}\ =\ (r_{i1},r_{i2},\ldots,r_{iM})^{T},i\in\{1,2,\ldots,L\}\), \(\sum\limits_{j\ =\ 1}^{M}r_{ij}\ =\ 1\), \(r_{ij}\in[0,1]\). Let \(\mathbf{F}\ =\ \left(f_{1},f_{2},\ldots,f_{L}\right)\) represent a classifier's feature selection matrix for the sample, where \(f_{i}\ =\ (f_{i1},f_{i2},\ldots,f_{iD})^{T},i\in\{1,2,\ldots,L\}\), \(\sum\limits_{j\ =\ 1}^{D}f_{ij}>0,f_{ij}\in\{0,1\}\). For a set of ensemble classifiers with resampling ratios and feature selection parameters, MPSO is used to solve the following problems:  
\[\begin{array}{c}\underset{s.t.}{max}\ \ Div_{1}(\mathbf{h})\\ \underset{i\ =\ 1}{\overset{F}{\sum}}\ r_{Li}\ =\ 1,r_{Li}\in[0,1]\\ \sum\limits_{i\ =\ 1}^{F}f_{Li}>0,f_{Li}\in\{0,1\}\end{array} \tag{19}\]  
Implement resampling and feature selection on the clustered subsets so that the training samples of each classifier are different. Use MPSO to optimize the sample resampling ratio and feature selection parameters of each classifier (i.e., individual learner). After training, a set of ensemble classifiers \(E_{i}\) with appropriate diversity are obtained. Let \(T_{max}\) represent the maximum number of iterations, \(SS\) represent the population size of the swarm, and \(\{B_{1},B_{2},\ldots,B_{M}\}\) represent the subset after clustering; the pseudocode of Algorithm 1 is as follows.  
```
1.Input:
2.\(M,SX_{i},\left[B_{1},B_{2},\ldots,B_{M}\right],T_{max},SS,L\)
3.Process:
4.// Initialize a population of particles, \(x_{j}^{0}(j\ =\ 1,2,\ldots,SS)\)
5.for\(j\ =\ 1\) to \(SS\)do
6.for\(l\ =\ 1\) to \(L\)do
7. Initialize \(f_{l},f_{l}\gets rand\{0,1\}\), \(\sum\limits_{j\ =\ 1}^{F}f_{ij}>0\);// At least one feature is selected
8. Initialize \(r_{l},\ r_{l}\gets rand\{0,1\}\), \(r_{l}\leftarrow\mathbf{r_{l}}/\sum\limits_{j\ =\ 1}^{M}r_{ij}\);
9. Resample \(\{B_{1},B_{2},\ldots,B_{M}\}\) according to \(r_{l}\), and then execute feature selection to generate a new dataset \(NS_{i}\);
10. Use \(NS_{i}\) to train the learner \(h_{l}\);
11. Use learner \(h_{l}\) to conduct the classification prediction on \(SX_{i}\), and obtain the category label;
12. End
13.\(x_{j}^{0}\leftarrow\left(f,\mathbf{r}\right)\)
14. Initialize \(\mathbf{Stk}^{0}\) and calculate \(\mathbf{Stickness}_{j}^{0}\);
15. end
16. Calculate the diversity measure \(Div_{1}(\mathbf{h})\) according to Equation (5);
17. Evaluate the fitness of particles, and set \(\mathbf{pbest}^{0}\) and \(\mathbf{gbest}^{0}\);
18.for\(t\ =\ 1\) to \(T_{max}\) do
19. for\(j\ =\ 1\) to \(SN\) do
20. Calculate the flipping probability using Equation (17);
21. Update the binary part of \(\mathbf{x}_{j}^{t}\) using Equation (18);
22. Update the continuous part of \(\mathbf{x}_{j}^{t}\) using PSO;
23. According to \(\mathbf{x}_{j}^{t}\) train and evaluate the learners;
24. end
25. Calculate the diversity measure \(Div_{1}(\mathbf{h})\) according to Equation (5);
26. Evaluate the fitness of particles, and set \(\mathbf{pbest}^{t}\) and \(\mathbf{gbest}^{t}\);
27. end
28.Output:\(F,R\)
```  
**Algorithm 1** Using MPSO to optimize the resampling ratio of subset and carry out feature selection