# Clustering Analysis of Wind Turbine Alarm Sequences Based on Domain Knowledge-Fused Word2 vec
## 4 The Proposed Method
### Clustering Alarm Sequences Based on WMD and WRD  
The goal of clustering is to group alarm sequences triggered by the same faults. Based on the vector representations of alarms obtained from DK-Word2 vec, the alarm sequences are represented as a sequence of vectors. Subsequently, the K-means algorithm is employed for clustering. To improve the performance of clustering, we use the WMD and WRD as the distance metric in K-means clustering.  
In natural language processing, considerable research has been conducted on sentence semantic similarity analysis based on word embeddings [29]. A sentence or document is a sequentially ordered collection of multiple words. A sentence can be represented as a sequence of vectors. The WMD and WRD are two effective methods for computing the similarity between sentences.  
The WMD is a pioneering work that introduced earth move's distance to the natural language processing field [30]. Let two alarm sequences be represented as \(s=(a_{1},a_{2},\ldots,a_{n})\) and \(s^{\prime}=(a^{\prime}_{1},a^{\prime}_{2},\ldots,a^{\prime}_{n^{\prime}})\), respectively. After mapping them using Word2 vec, they become the corresponding vector sequences \(\mathbf{s}=(\mathbf{a}_{1},\mathbf{a}_{2},\ldots,\mathbf{a}_{n})\) and \(\mathbf{s}^{{}^{\prime}}=(\mathbf{a}^{{}^{\prime}}_{1},\mathbf{a}^{{}^{\prime }}_{2},\ldots,\mathbf{a}^{{}^{\prime}}_{n^{\prime}})\), where \(\mathbf{a}_{i},\mathbf{a}^{{}^{\prime}}_{j}\in\mathbb{R}^{N}\), and \(N\) is the dimensionality of the word embedding. It is the minimum cumulative cost of moving \(\mathbf{s}\) to \(\mathbf{s}^{{}^{\prime}}\) given the constraints. We allow each alarm \(\mathbf{a}_{i}\) in \(\mathbf{s}\) to be transformed into any alarm in \(\mathbf{s}^{{}^{\prime}}\) in total or parts. The dissimilarity between two alarm sequences can be expressed as  
\[\text{WMD}=\underset{\gamma_{ij}\geq 0}{\text{min}}\underset{i,j}{\sum}\gamma_{i,j} \Big{\|}\mathbf{a}_{i}-\mathbf{a}^{{}^{\prime}}_{j}\Big{\|}\text{ s.t.}\sum_{j}\gamma_{i,j}=\frac{1}{n},\sum_{i}\gamma_{i,j}=\frac{1}{n^{\prime}}, \tag{9}\]  
where \(\gamma_{i,j}\) denotes how much of the alarm \(\mathbf{a}_{i}\) in \(\mathbf{s}\) travels to the alarm \(\mathbf{a}^{{}^{\prime}}_{j}\) in \(\mathbf{s}^{{}^{\prime}}\).  
The WRD is based on the concept of rotating one word's vector towards the other word's vector to align their directions [31]. The idea is that this rotation captures the underlying semantic relationship between the words, and the degree of rotation needed represents their similarity or dissimilarity. Formally, WRD is calculated as the minimum angle of rotation needed to align vector \(\mathbf{a}_{i}\) to vector \(\mathbf{a}_{j}\) in a higher-dimensional space and is expressed as  
\[\text{WRD}=\underset{\gamma_{ij}\geq 0}{\text{min}}\underset{i,j}{\sum}\gamma_{i,j} \Bigg{(}1-\frac{\mathbf{a}_{i}\cdot\mathbf{a}^{{}^{\prime}}_{j}}{\|\mathbf{a} _{i}\|\times\|\mathbf{a}^{{}^{\prime}}_{j}\|}\Bigg{)}\text{ s.t.}\sum_{j}\gamma_{i,j}=\frac{\|\mathbf{a}_{i}\|}{Z},\sum_{I} \gamma_{i,j}=\frac{\|\mathbf{a}^{{}^{\prime}}_{j}\|}{Z^{\prime}}, \tag{10}\]  
where \(Z=\underset{i=1}{\overset{n}{\sum}}\|\mathbf{a}_{i}\|\), \(Z^{\prime}=\underset{j=1}{\overset{n^{\prime}}{\sum}}\|\mathbf{a}^{{}^{\prime} }_{j}\|\), and \(\gamma_{i,j}\) denotes how much of alarm \(\mathbf{a}_{i}\) in \(\mathbf{s}\) travels to alarm \(\mathbf{a}_{j}\) in \(\mathbf{s}^{{}^{\prime}}\).