# A New Method of Time-Series Event Prediction Based on Sequence Labeling
## 2 Definitions and Methods
### CX-LC Framework
#### 2.2.1 Patterns Recognition  
One of the key problems of sequence marking is how to extract the features of sub-segments as the input of the model. In the existing literature, the original data of the subsequence set are used as input, which ignores the conversion relationship between various patterns in the subsequence set, and is easily affected by noise such as outliers in the original data. Using representative patterns in time series, effective and interpretable time series modeling can be carried out. In this paper, the subsequence is recognized as a weighted combination of multiple patterns, and then the characteristics of the patterns are used as the model input, which can improve the robustness of the model. First, identify V sequence patterns from the original data set \(\{T_{1},T_{2},\ \ldots,T_{N}\}\). Experiments show that [10], as V increases, the prediction accuracy rate may not necessarily increase, so V is an empirically determined value. This paper uses the cluster algorithm to recognize patterns. Taking Kmeans [22] as an example, the purpose of the algorithm is to divide the \(N\times K\) segment \(X_{t}\) into \(|V|\) classes--the set of classes is \(\Omega=\{\Omega_{1},\ \ldots,\Omega_{|V|}\}\)--and then extract the representative model of each class by minimizing the sum of squares within the cluster. The specific formula is as follows:  
\[\operatorname*{arg\,min}_{\Omega}\sum_{v\in\mathcal{V}}\sum_{X_{t}\in\Omega_ {v}}\|X_{t}-\Theta_{v}\|^{2}=\operatorname*{arg\,min}_{\Omega}\sum_{v\in \mathcal{V}}|\Omega_{v}|\operatorname*{Var}\Omega_{v}, \tag{1}\]  
where \(\Theta_{v}\) is the average value of all segments in \(\Omega_{v}\). Thus, the pattern set \(\Theta=\{\Theta_{1},\Theta_{2},\ \ldots,\Theta_{V}\}\) of the data set is obtained. Figure 1: Labeling Prediction Method. As shown in the figure, the first subsequence set \(T_{1}^{r}\) is regarded as the observation \(A_{1}\), the to-be-predicted value \(Y_{r\ +\ 1}\) is regarded as annotated label \(B_{1}\), and the second subsequence set \(T_{2}^{r}\) is the same. The problem conversion is carried out in turn, and the event prediction problem can be converted into a sequence labeling problem. After obtaining the mode set as \(\Theta\), the subsequence can be expressed as a weighted combination of modes. For a given state \(\Theta_{v}\) and a subsequence \(X_{k}\), the distance between the two can be normalized to the identification weight. In this article, Euclidean distance and the linear function normalization method (Min-Max scaling) are used:  
\[D(X_{k},\Theta_{v})=\|X_{k}-\Theta_{v}\|^{2} \tag{2}\]  
\[P(\Theta_{v}\mid X_{k})=\frac{\max\bigl{(}[\mathcal{D}(X_{t},\Theta_{v})]_{v \in\mathcal{D}}\bigr{)}-\mathcal{D}(X_{t},\Theta_{v})}{\max\bigl{(}[\mathcal{D }(X_{t},\Theta_{v})]_{v\in\mathcal{D}}\bigr{)}-\min\bigl{(}[\mathcal{D}(X_{t},\Theta_{v})]_{v\in\mathcal{D}}\bigr{)}}. \tag{3}\]  
\(P(\Theta_{v}|X_{k})\) is the probability of recognizing the subsequence \(X_{k}\) as the state \(\Theta_{v}\), that is, the weight of \(\Theta_{v}\) in the pattern combination of \(X_{k}\). Each subsequence \(X_{k}\) can be calculated to obtain V identification weights, expressed as \(Prob_{k}=\{P(\Theta_{1}|X_{k}),P(\Theta_{2}|X_{k}),\ \ldots,\ P(\Theta_{V}|X_{k})\}\); so, based on the pattern representation, the feature set of the subsequence set \(T_{m}^{\tau}\) can be obtained as \(TProb_{m}^{\tau\times V}=\{Prob_{m},Prob_{m+1},\ \ldots,Prob_{m+\tau-1}\}\). In order to illustrate how pattern recognition reveals the evolution of time series and helps predict events, this paper conducted an observational study on the PM2.5 data set (see Section 3.1 for details on the data set). Take the data of a certain air detection station as an example, the detection station can obtain an observation value of PM2.5 every day (i.e., \(D=1\)) and divide the data with one week as a subsequence (i.e., \(L=7\)).