# Using Hybrid LSTM Neural Networks to Detect Anomalies in the Fiber Tube Manufacturing Process
## 2 Materials and Methods
### Preprocessing of Input Data for Training Set
The left column (Figure 2a,c,e,g,i,k) corresponds to the decomposition of the signal recorded during the measurement session from the RLM production line using a 4-octave Haar-based DWT, while the right column (Figure 2b,d,f,h,j,l) corresponds to the decomposition of the same signal using a 2-octave Haar-based DWT. The waveforms (Figure 2a-d) show example sections of RLM line acceleration, in which the time interval \(\left\langle S_{B},\ldots,S_{E}\right\rangle\) is marked with a rectangular area. The symbols \(S_{B}\) and \(S_{E}\), denote the start of the fiber twisting process and the end of the twisting process of a given tube section, respectively. Graphs (Figure 2e-h) contain waveforms for the ongoing basic production process also for two different randomly selected sessions. The recorded process data from the RLM line \(X\in R^{S_{N}\times W_{S}}\), were normalized \(\left\{a=0,b=1\right\}\) for each signal channel data independently:  
\[x_{i,j,\text{norm}}=a+(b-a)\cdot\frac{x_{i,j}-min(X_{i,:})}{max(X_{i,:})-min(X_ {i,:})} \tag{3}\]  
where: \(X_{i}\) is the \(i\)-th row of \(X\). The plots (Figure 2i-l) show sample stages of the finalization of the fiber twisting process for a given tube section, marked as \(\left\langle C_{B},\ldots,C_{E}\right\rangle\), where the symbols \(C_{B}\) and \(C_{E}\) denote the start and end of the production completion process for the given tube section, respectively. All plots marked with the number 3 represent an attempt to visualize the potential membership of the production process state to a priori selected number of classes. Subsequently, a univariate feature selection algorithm for classification using the Chi-square test was applied. This allowed for the visualization and assessment of the importance of individual leading features in the recorded data stream, represented as a cluster structure corresponding to 32 different process states, as shown in Figure 3. The Table 3 contains the coordinates and names of the individual leading components of the process. Figure 3: Input data significance distribution. In the course of observing the impact of individual process characteristics on cluster distribution, it was found that it is possible to use an automatic clustering mechanism to construct a training set for Deep Neural Networks (DNN). At the same time, it was noted that the DWT showed high sensitivity to momentary impacts of some parameters, such as the state of the cable length counter when changing the winding drum. Such a phenomenon caused strong interference, which negatively affected the segmentation process of individual process states. In addition, for analytical purposes, the authors attempted to graphically interpret the distribution of individual clusters and the distance between them, using the Hierarchical Clustering with Binary Clustering Tree method. Assuming that the given is a dataset with \(n\) observations, where each observation is represented as a \(d\)-dimensional vector \(\mathbf{x}_{i}=(x_{i1},x_{i2},\ldots,x_{id})\), the steps for agglomerative hierarchical clustering we obtained by iterative merging: by serching for the pair of clusters \(\left(C_{i},C_{j}\right)\) with the smallest distance \(d\left(C_{i},C_{j}\right)\). Then merging clusters \(C_{i}\) and \(C_{j}\) into a new cluster \(C_{ij}\) and eventually update the distance matrix to reflect the distance between consecutive new cluster \(C_{ij}\) and all other. As the linkage criteria we assumed the average distance method to measure the distance between clusters:  
\[d\left(C_{i},C_{j}\right)=\frac{1}{|C_{i}||C_{j}|}\sum_{\mathbf{x}_{i}\in C_{i }}\sum_{\mathbf{x}_{i}\in C_{j}}d\left(\mathbf{x}_{\mathbf{\alpha}_{i}}, \mathbf{x}_{\mathbf{b}}\right) \tag{4}\]  
By the repetition of merging loop we obtained a Binary Clustering Tree of the monitored process clusters. This preliminary preprocessing of RLM line data we performed for all sessions and the resulting dendrogram and 3D view of the most significant components are shown on the Figure 4 respectively.