## 3 Methods  
### Overview  
The challenge of unsupervised time-series anomaly detection lies in accurately identifying whether a segment of evenly spaced time series \(x_{1:L}=\{x_{1},x_{2},...,x_{L}\}\in R^{L\times N}\) contains anomalies without labeled data. Here, \(L\) represents the number of time steps in the input, and \(N\) denotes the number of variables considered. Inspired by the DaViT model, we propose a novel method called STformer, as illustrated in Figure 2. The uniqueness of this model lies in its ability to simultaneously capture complex patterns within both the temporal and feature (channel) dimensions of time-series data. It also integrates the Uniform Manifold Approximation and Projection (UMAP) technique--an efficient dimensionality reduction method--further enhancing the model's performance and making it suitable for real-time processing in practical applications. Specifically, we first apply UMAP to reduce the original \(N\)-dimensional time-series data to \(M\)-dimensions (\(M<N\)), resulting in the simplified dataset \(x_{1:L}\in R^{L\times N}\). This step preserves the most important features while eliminating unnecessary data redundancy, thus improving the overall efficiency of anomaly detection. Next, we perform an embedding operation on the \(M\)-dimensional dataset \(x_{1:L}\in R^{L\times N}\), mapping it into a higher-dimensional space. This embedding process enables us to capture the intricate interactions between the temporal and feature dimensions while retaining critical time-series patterns. By mapping the features of each time step into a higher-dimensional space, the model is better equipped to learn complex patterns. Then, we introduce the Time-Block component to specifically analyze temporal dependencies within the time series, enhancing the understanding of how data evolves over time. Following this, the Variable-Block module explores the interactions and dependencies between different variables, a crucial step for fully grasping the hidden complex mechanisms underlying time-series data. The overall structure of the model is formalized in Equation (5) as follows:  
\[ \begin{split} x^{0}=Embeding(UMAP(x_{in}))\\ x^{k}=\text{ Time}-\text{Block}(x^{k-1})\\ x_{out}=\text{ Variable}-\text{Block}(k^{s})\end{split}  \tag{5}\]  
where the initialization of the input is denoted as \(x_{in}\in R^{L\times N}\). Embedding linearly projects \(x_{in}\) to \(x_{u}^{0}\in R^{L\times d_{model}}\). \(x^{k}\in\mathbb{R}^{L\times d_{model}}\) represents the output of the Time Block. By minimizing the reconstruction error, the loss value decreases, and the model parameters are updated. The loss function is defined as shown in Equation (6). The training process is as shown in Algorithm 1. \[loss=||x_{in}-x_{out}||^{2} \tag{6}\]```
Input: Input sample \(x_{in}\) Output: Output value \(x_{out}\)
1 for\(i=1\) to epochdo
2 for\(j=1\) to batchdo
3\(x_{0}^{j}=\text{Embedding}(\text{UMAP}(x_{in}^{j}))\);
4 for\(k=1\) to \(K\)do
5\(x_{k}^{j}=\text{Time-Block}(x_{k-1}^{j})\);
6\(x_{k}^{j}=\text{Variable-Block}(x_{k}^{j})\);
7
8 end for
9 Update model parameters;
10
11 end for
```

**Algorithm 1**Training algorithm

In Algorithm 1, the term epoch refers to the number of iterations of model training. In each epoch, the data are divided into several equal-sized batches, and the data in each batch are used to compute the loss value and update the model parameters once using an optimizer. Here, \(K\) represents the number of Time Blocks and Variable Blocks in STformer. During the testing phase, the process of anomaly detection algorithm is as shown in Algorithm 2.