## 4 Methodology
### Model Training  
To make the features extracted by the proposed feature extraction network meet the optimization objectives defined in Section 4.3 as much as possible, we propose a two-stage training method. Figure 6 demonstrates the flow of the two-stage training method. In the first stage, we utilize the stochastic gradient descent (SGD) optimization method to optimize the model parameters and the loss function is contrastive loss. The SGD optimization method is used to train the feature extraction network proposed in Section 4.2. The contrastive loss is as shown in Formula (9). \[L\left(W,\left(Y,\vec{X}_{1},\vec{X}_{2}\right)\right)=\frac{1}{N}\sum_{n=1}^ {N}YD_{W}^{2}+(1-Y)\max(m-D_{W},0)^{2} \tag{9}\]  
where \(W\) is the weight of the model, \(N\) is the size of the training data, \(\vec{X}_{1}\) and \(\vec{X}_{2}\) represent the features of samples \(X_{1}\) and \(X_{2}\), respectively, the value of \(Y\) is determined by the categories of samples \(X_{1}\) and \(X_{2}\) (if \(X_{1}\) and \(X_{2}\) do not belong to the same category, then \(Y=0\)otherwise, \(Y=1\)), \(D_{w}\) is an abbreviation for \(D_{W}\Big{(}\vec{X}_{1},\vec{X}_{2}\Big{)}\) (representing the Euclidean distance between \(\vec{X}_{1}\) and \(\vec{X}_{2}\)), and \(M\) is the set threshold. As can be seen in (9), when \(Y=1\), the model training process can minimize the distance between \(\vec{X}_{1}\) and \(\vec{X}_{2}\) by adjusting parameters. When \(Y=0\) and the distance between \(\vec{X}_{1}\) and \(\vec{X}_{2}\) is greater than \(m\), there is no need to optimize parameters. When the distance between \(\vec{X}_{1}\) and \(\vec{X}_{2}\) is less than \(m\), the distance between \(\vec{X}_{1}\) and \(\vec{X}_{2}\) needs to be increased to \(m\). Therefore, the use of contrastive loss can increase the scatter between different categories. However, the contrastive loss function is mainly used to increase between-class scatter, without considering within-class scatter. According to the description in Section 4.2, shapelet transformation is mainly completed at the distance calculation layer. Therefore, in the second stage of training, we use the differential evolution (DE) algorithm and the training data to optimize the weights of the distance calculation layer in the first stage of training, with the goals of better meeting the requirements of the Fisher criterion and further improving the classification performance of the model. The DE algorithm is an optimization algorithm based on swarm intelligence theory, which has the advantages of fast convergence speeds, high reliability, high efficiency, robustness, and strong global search ability [37]. It has been widely used in many optimization problems [38; 39; 40]. The main steps of the second stage of training are as follows. Step 1: Population initialization. To achieve better optimization results, individuals in the initialized population should cover the solution space as much as possible. The range of the solution space is determined by the upper \(x_{\max}\) and lower \(x_{\min}\) of weights, while the dimensions of the individual vectors are related to the length and number of shapelets, assuming that the length and number of shapelets are \(M\) and \(K\), respectively. We chose to focus on three key performance indicators from the drive test data, so the dimension of the individual vector is \(D=M\times K\times 3\) and the \(i\)-th individual in the initial population is \(X_{i}=\big{\{}x_{i}^{1},x_{i}^{2},\ldots,x_{i}^{D}\big{\}},i=1,2,\ldots,NP\), where \(NP\) is the number of individuals in the initial population. The \(j\)-th element in the individual vector is as shown in Formula (10). \[x_{i}^{j}=x_{\min}+rand(0,1)\cdot(x_{\max}-x_{\min}),\ j=1,2,\ldots,D \tag{10}\]  
Step 2: Fitness evaluation. In this paper, in order to calculate the fitness of an individual, firstly, the individual vector needs to be substituted into the distance calculation layer of the feature extraction network as the weights of the distance calculation layer.