# Research on a Mixed Gas Classification Algorithm Based on Extreme Random Tree
## 2 Hybrid Gas Detection Method
### Principal Component Analysis  
The principal component analysis (PCA) method is a commonly used statistical method [50]. By calculating the original data covariance matrix, the high-dimensional data are transformed into low-dimensional data and the correlation between the dimensions is determined. The purpose of principal component analysis is to reduce noise and redundancy. The noise reduction is to ensure that the correlation between the processed data is as small as possible. The redundancy is removed to maximize the variance of the processed data [51; 52]. Suppose that there are \(p\) sensors, \(n\) samples are collected and a matrix X is formed. The number of rows of X is \(n\), and the dimension is \(p\), which can be expressed in the form of a column vector, as shown in Equation (7):  
\[X=\left[ \begin{array}{ccc}x_{11}&\cdots&x_{1p}\\ \vdots&\ddots&\vdots\\ x_{n1}&\cdots&x_{np}\end{array} \right]. \tag{7}\]  
Convert the \(p\)-dimensional data into linear combinations of \(p\) variables:  
\[\left\{ \begin{array}{c}y_{1}=l_{11}x_{1}+l_{12}x_{2}+\cdots l_{1p}x_{p}\\ y_{2}=l_{21}x_{1}+l_{22}x_{2}+\cdots l_{2p}x_{p}\\ \vdots\\ y_{m}=l_{m1}x_{1}+l_{m2}x_{2}+\cdots l_{mp}x_{p},\end{array} \right. \tag{8}\]  
where \(y_{1},y_{2},\cdots y_{m}(m\leq p)\) are the values after the linear transformation and the equation satisfies the following conditions: (1) \(y_{1},y_{2},\cdots y_{m}(m\leq p)\) are irrelevant to each other. (2) The magnitude relationship of the variance is \(y_{1}>y_{2}>\cdots>y_{m}\) (3) \({l_{m1}}^{2}+{l_{m2}}^{2}+\ldots+{l_{mp}}^{2}=1\). Therefore, \(y_{1},y_{2},\cdots y_{m}(m\leq p)\) represents the \(1,2,3\ldots m\) principal components of the initial variables, \(x_{1},x_{2},\cdots x_{p}\), and \(l_{mp}\) is called the principal component coefficient. The specific implementation steps of the principal component analysis are as follows:  
(1) Standardize the raw data  
The PCA is a data-based covariance matrix. The size of the data varies. To keep the dimensions of the data consistent, the data should be standardized first. Subtract the data from the mean of the dimension and divide by the standard deviation of the dimension. \[X_{i}^{*}=\frac{X_{i}-E(X_{i})}{\sqrt{D(X_{i})}}(i=1,2,\ldots p). \tag{9}\]  
\(E(X_{i})\) represents the mean of the data, and \(D(X_{i})\) represents the variance of the data. (2) Calculate the covariance matrix of the data  
The covariance matrix of the normalized data is the correlation coefficient matrix of the original variables. The derivation is as shown in Equation (10). \[\  
The correlation coefficient matrix \(R\) can be expressed as:  
\[R=\left( \begin{array}{ccc}r_{11}&\ldots&r_{1p}\\ \vdots&\ddots&\vdots\\ r_{p1}&\ldots&r_{pp}\end{array} \right). \tag{11}\]  
From the feature equation, \(|R-\lambda E|=0\), solving for the eigenvalue of the correlation coefficient matrix yields \(\lambda_{i}(i=1,2,3\ldots p)\), and the eigenvectors are ordered by the eigenvalues from large to small, \(\lambda_{1}\geq\lambda_{2}\geq\ldots\geq\lambda_{p}\geq 0\). Substitute \(\lambda_{i}\) into \((R-\lambda_{i}E)x=0\). Solve for the feature vector, \(a_{i}\), and unitize \(a_{i}\) into \(e_{i}\). (4) Find the principal component by calculating the cumulative contribution rate. Calculate the cumulative contribution rate of the aligned eigenvalues. Generally, when the top t features are worth accumulating, they have a cumulative contribution rate of 85%-95%; one can take these t features as the main components:  
\[sum=\frac{\lambda_{i}}{\sum\lambda_{i}}. \tag{12}\]  
(5) Find the load of the principal component. \[l_{ij}=\sqrt{\lambda_{i}}e_{ij}(i,j=1,2,\ldots,p). \tag{13}\]  
The principal component, \(Y=(y_{1},y_{2},\ldots,y_{m})^{T}\), is obtained from Equation (8). To illustrate the discreteness of the data features, I abstracted all the data and each category into three-dimensional features. As shown in Figure 3, the features have obvious discrete types, and the traditional single dimension algorithm cannot complete the classification.