## 2 Materials and Methods
### Methods
#### 2.2.2 Multi-Scale Partitioning  
Multi-scale partitioning could be easily extended to the multivariable case by independently considering each variable. In the multi-scale module, we defined a set \(S\) = {\(S_{1}\),..., \(S_{M}\)} that contained \(M\) patch size values, where each patch size S corresponded to a patch partitioning operation. For the input time series \(X_{i}\in R^{H\times d}\), where H represents the length of the time series and d represents the dimensionality of the features, the partitioning operation for a patch size \(S\) divides X into P patches, (\(X_{1}\), \(X_{2}\),..., \(X_{P}\)), where each patch \(X_{i}\in R^{S\times d}\) contained \(S\) time steps. As shown in Figure 5.  
Figure 4: The flowchart of the proposed method.  
The extraction of periodic components was primarily achieved through the DFT. By applying the DFT to the input time series X, it was converted from the time domain to the frequency domain. \(f_{k}\) represents a single frequency component.  
\[X_{f}=\text{DFT}(X)=\{f_{1},f_{2},\dots,f_{x}\} \tag{1}\]  
The amplitudes of various frequency components were computed, and the Top \(K_{f}\) frequencies with the largest amplitudes were selected. This selection process not only ensured the sparsity of the frequency domain but also effectively retained the most important frequency components, thereby reducing redundant information. \(K_{f}\) represented the number of selected frequency components.  
\[X_{f}=\text{TopK}(\{X_{f}\},K_{f}) \tag{2}\]  
The amplitudes of various frequency components were computed, and the Top \(K_{f}\) frequencies with the largest amplitudes were selected. This selection process not only ensured the sparsity of the frequency domain but also effectively retained the most important frequency components, thereby reducing redundant information.  
\[X_{f}(t)=\sum_{k=1}^{K}A_{k}\text{cos}(2\pi f_{k}t+\varphi_{k}) \tag{3}\]  
\(A\) and \(\Phi\) represent the amplitude and phase of the selected frequencies, respectively.  
Using the IDFT, the selected frequency components were converted back to the time domain to obtain the periodic part \(X_{f}\), reconstructing the periodic fluctuations in the time series, as described by the following formula.  
\[X_{s}=\text{IDFT}(X_{f},K_{f}) \tag{4}\]  
The residual component was then averaged through pooling using kernels of different sizes. Multiple convolution operations were performed on the residual component with different pooling kernels, and the output for each kernel was computed. Subsequently, the SoftMax function was applied to determine the weight of each kernel. \(Y_{k}\) represents the output value after the pooling operation.  
\[Y_{k}=Avgpool(X_{s},kernel) \tag{5}\]  
The features of each segment were normalized using the SoftMax function to obtain the corresponding weights.  
Figure 5: Multi-scale partitioning.  
\[W_{k}=\frac{\exp(Y_{k})}{\sum_{i-1}^{p}\exp(Y_{i})} \tag{6}\]  
The periodic components captured cyclical fluctuations, while the trend components reflected long-term changes in the time series. The TopK selection mechanism allowed us to retain the most important path weights, thereby optimizing the feature extraction process. The pseudocode of feature selection is shown in Algorithm 2.  
\[F=\sum_{k=1}^{K}W_{k}Y_{k} \tag{7}\]  
\[W_{path}=softmax(F) \tag{8}\]  
\[TopK(W_{path},K) \tag{9}\]  
```
Input: Time series \(X\)\(\in\)R\({}^{H\times d}\). Number of K. Output: Selected_k
1. Perform DFT on the input time series \(X\) to obtain frequency components;
2. \(X_{f}\) = DFT (\(X\)):
3. \(X_{f}\) = TopK(\(\{X_{f}\}\),K)
4. \(X_{s}\) = IDFT(\(X_{f}\))
5. Pooling (\(X_{f}\), kernel)
6. For size in kernel
7. Apply the pooling operation to the input \(X_{f}\)
8. Return \(X_{pool}\)
9. For weights in SoftMax weights
10. Calculate the SoftMax weight of each pooling kernel output
11. Return selected_K
12. Selected_K = TopK (\(X_{pool}\), K)
```  
**Algorithm 2**Feature Selection using DFT