# Drowsiness Transitions Detection Using a Wearable Device
## 2 Methodology  
Anomaly detection, often known as the identification of anomalous data, is the process of identifying patterns in certain data that behave differently from how they should. This type of analysis is fundamental since the abnormal points can indicate significant information about the process, even rare events, allowing the implementation of preventive measures. Anomaly detection is being applied in different contexts: like medical and public health, fraud detection, industrial, image processing, text data, and sensor networks. The three known techniques are based on classification, statistical, and clustering methods. Classification methods can be computed considering, for example, support vector machine (SVM), Bayesian network (BN), rule-based, or neural network (NN). In terms of statistical methods, mixture models, signal processing, process control, and principal component analysis are widely used, and for the clustering method, there is regular clustering or coclustering [22; 23]. The process control method is useful to monitor the performance of the process and recognize when an anomaly is detected. The anomaly can happen when the process does not work as expected and defined. Thus, there are some visual techniques that can be implemented to understand the behavior of the process while it is being analyzed and that can be applied to visualize one variable (univariate analysis) or more than one (multivariate analysis), known as control charts [24]. However, there are some disadvantages of this method, as the problem can be misleading, and sometimes, it is not easy to interpret the results achieved on account of the strong correlations between the attributes, also defined as collinearity. Besides that, there are also others problems, like the high number of attributes to take into consideration, known as the dimensionality, the noise in the data due to external factors, and missing data [25]. Principal Component Analysis (PCA) is a method that has been developed to streamline monitoring process analysis, address the dimensionality problem, and prevent collinearity between the characteristics. This technique transforms a large number of features into low-dimensional spaces, where the principal components are expressed as a linear combination of the original features, that are orthogonal and explain the original information. The first principal component has a higher variability from the original data [24]. The matrix \(\mathbf{X}\in\mathbb{R}^{N\times M}\) represents the data that is going to be analyzed considering the number of observations (\(\mathbf{N}\)) and the number of features (\(M\)) of the process. For better results, the values in \(\mathbf{X}\) must be standardized, meaning, a mean equal to zero and unit variance. In terms of the number of principal components, \(R\), to take into consideration, it depends on the goal of the analysis. If the aim is to reduce the colinearity between the features, the \(R\) value can be equal to the number of the original features. However, if it is more important to reduce dimensionality, the number of principal components can be set to those that have higher variability. Therefore, the number of components can be expressed as \(R\leq M\) and the principal components is defined as Equation (1),  
\[\mathbf{T}=\mathbf{X}\mathbf{P}+\mathbf{E} \tag{1}\]  
where the scores matrix is given by \(\mathbf{T}\in\mathbb{R}^{N\times R}\), the loading matrix given by \(\mathbf{P}\in\mathbb{R}^{M\times R}\), and the information that is not explained by the PCA method is defined as an error (\(\mathbf{E}\in\mathbb{R}^{N\times R}\)). Moreover, the estimation of the original features \(\left(\mathbf{\hat{X}}\right)\) and the residuals \(\left(\mathbf{\hat{E}}\right)\) can be expressed by Equations (2) and (3), respectively [24; 26; 27].