## 4 Experiment and Results
### Performance Metrics  
To evaluate the performance of the proposed model, SPT-AD, five evaluation metrics, namely the accuracy, precision, recall, F1-score, and AUROC curve, were used as performance indicators in this study.  
\begin{table}
\begin{tabular}{l l} \hline
**Parameter** & **Value** \\ \hline learning rate & 0.0001 \\ summary\_steps & 500 \\ max\_steps & 10,000 \\ batch\_size & 32 \\ window\_size & 512 \\ n\_features & 3 \\ patch\_size & 4 \\ d\_embed & 512 \\ n\_layer & 6 \\ dropout & 0.1 \\ window\_sliding & 256 \\ r\_level & 3 \\ r\_size & 256, 128, 64 \\ loss function & BCE \\ \hline \end{tabular}
\end{table}
Table 5: Hyperparameter settings.  
Accuracy is a metric that measures the percentage of all predictions made by a model that match the true value. This gives you an idea of how accurately the model is at predicting.  
\[\text{Accuracy}=\frac{\text{TP}+\text{TN}}{\text{TP}+\text{FN}+\text{FP}+ \text{TN}} \tag{21}\]  
T and P are true and false, respectively, for whether the model predicted correctly, and P and N are positive and negative, respectively, for whether the value predicted by the model was positive or negative. This is a metric that evaluates how many of the total predictions are correct, like a formula, but it can overestimate performance in data-imbalanced environments where only certain classes of data are abundant.  
Precision is a measure of the percentage of true positives (TP) in the actual data that the model predicts are actually positive. Precision indicates how accurate the results predicted to be positive are.  
\[\text{Precision}=\frac{\text{TP}}{\text{TP}+\text{FP}} \tag{22}\]  
Recall is a measure of the percentage of positives in the actual data that the model predicts are positive. Recall indicates how well the model predicts positives without missing any.  
\[\text{Recall}=\frac{\text{TP}}{\text{TP}+\text{FN}} \tag{23}\]  
The F1-score is a metric used to evaluate the performance of a binary classification model, measuring balanced performance through the harmonic mean of precision and recall. Precision refers to the proportion of positive predictions that are actually positive, while recall refers to the proportion of true positives that the model correctly predicts. The F1-score has a value between 0 and 1, with higher values indicating a model that balances precision and recall.  
\[\text{F1-score}=2\times\frac{\text{Precision}\times\text{Recall}}{\text{ Precision}+\text{Recall}} \tag{24}\]  
F1 is the product of precision and recall. Unlike precision, it is susceptible to smaller values, allowing models to be evaluated effectively in data-imbalanced environments.  
The curve that evaluates the performance of a model as the threshold between 0 and 1, which determines whether a prediction is true or false, is called the ROC curve. The area under the ROC is called the AUC. The AUC value is a value between 0 and 1, and the closer it is to 1, the better the performance.  
\[AUROC=\int_{0}^{1}\text{True Positive Rate (TPR)}\cdot d(\text{False Positive Rate (FPR)}) \tag{25}\]  
These performance metrics were used to quantify and compare the time series anomaly detection performance of SPT-AD models. They provide a comprehensive view of the model's performance by evaluating the model's accuracy, precision, recall and F1-score.