# A New Method of Time-Series Event Prediction Based on Sequence Labeling
## 2 Definitions and Methods
### CX-LC Framework
#### 2.2.4 Smooth Prediction  
Probabilistic graphical models are a type of model with a sound theoretical foundation and good application effects in machine learning. Especially the Markov Random Field (MRF) and its variant CRF have been developed as an effective method to improve the accuracy of sequence labeling. Since the time-series are arranged in a linear chain, the linear chain conditional random field (linear-CRF) is often used for sequence labeling. In the problem of time-series event prediction, the subsequence set \(TProb^{Q}=\{TProb_{1}^{Q},TProb_{2}^{Q},\ \ldots,TProb_{M}^{Q}\}\) is the observation sequence, and the event value \(Y=\{Y_{1+\tau},Y_{2+\tau},\ \ldots,Y_{m+\tau}\}\) is the output tag sequence; according to the definition of CRF, under the condition given by \(TProb^{Q}\), the conditional distribution of Y satisfies the Markov property:  
\[P\Big{(}Y_{m}\mid\text{TProb}^{Q},Y_{1},\ldots,Y_{m-1},Y_{m+1}\ldots,Y_{M} \Big{)}=P\Big{(}Y_{m}\mid\text{TProb}^{Q},Y_{m-1},Y_{m+1}\Big{)}. \tag{10}\]  
Therefore, according to the Hammesley theorem [27], the joint probability \(P(Y)\) can be decomposed into the product of multiple potential functions based on the maximal clique:  
\[P(Y)=\frac{1}{Z}\prod_{c_{i}\in\mathbb{C}}\Psi_{c_{i}}(Y_{c_{i}}) \tag{11}\]  
\[Z=\sum_{Y}\prod_{c_{i}\in\mathbb{C}}\Psi_{c_{i}}(Y_{c_{i}}), \tag{12}\]  
where \(Z\) is the normalization factor, the subset of nodes with edges connected between any two nodes is a \"clique\" \(c_{i}\), the set of all cliques is \(\mathbb{C}\). \(\Psi_{c_{i}}\) is called the potential function, and each potential function is only related to one clique, is a non-negative real function defined on a subset of variables, usually constructed as an exponential function, used to define the probability distribution function. Due to the linear chain structure of linear-CRF (as shown in Figure 4), the two adjacent events \(Y_{m-1}\) and \(Y_{m}\) form a maximal clique, and the parameterized form of linear-CRF can be obtained:  
\[P(Y=Y_{m}\mid\text{T}^{\text{T}})=\frac{1}{Z(x)}\exp\left[\sum_{m\
eq k}\lambda _{k}t_{k}\Big{(}Y_{m-1},Y_{m},\text{TProb}^{Q},m\Big{)}+\sum_{m\
eq 1}\mu_{i}S_{t} \Big{(}Y_{m},\text{TProb}^{Q},m\Big{)}\right], \tag{13}\]  
where \(t_{k}\) is the transition characteristic function defined on the edge, which depends on the current and previous positions (also called binary score), and \(S_{t}\) is the state characteristic function defined on the point, which depends on the current position (also called the unary score).  
In the combination of LSTM-CRF, the value of \(S_{l}\) is the output of LSTM (i.e., the preliminary prediction value \(\hat{Y}_{m+\tau}\)) and \(t_{k}\) is the label transition matrix obtained by training CRF. When calculating \(P(Y_{m}\mid TProb^{Q})\), the logarithm is usually taken to obtain \(logP(Y_{m}\mid TProb^{Q})\) and then the forward algorithm [28] is used to calculate. Similarly, the LSTM-CER model can use the Adam optimizer for parameter optimization and use the negative log-likelihood function as the loss function :  
\[\text{loss}=-\log P\Big{(}\text{Y}\mid\text{TProb}^{Q}\Big{)}. \tag{14}\]