## 4 Experimental Design
### Data Pre-Processing
In order to facilitate the subsequent feature extraction and improve the real-time of the system model, the number of subcarrier inputs was reduced as much as possible. In order to select the subcarriers with obvious features, the PCA algorithm was deployed to calculate the principal components of each subcarrier and to select the subcarriers with better principal components for the next step. The PCA refers to a method that recombines the input variables into new variables by using some methods to extract fewer variables from them to reflect as much information changes of the original variables as possible based on the actual needs. The selection is made by comparing the variance of each subcarrier. The larger the variance, the more information the subcarrier contains, and the largest variance is the first principal component. The PCA steps are listed as follows:  
1. Find the covariance matrix C of the data. 2. Find the matrix eigenvalues and the corresponding eigenvectors from the covariance matrix. 3. Normalize eigenvectors and eigenvalues. 4. Reduce the dimensionality of the data. Referring to [21], the principal components contained in the 30 subcarriers were extracted and implanted in the same coordinate system. As noise was removed in the prior step, only the principal component with the best effect on noise reduction was selected. Figure 6: The above figure shows the before and after comparison of wavelet processing algorithm: (**a**) Before filtering and denoising; (**b**) After filtering and denoising. Figure 7 shows the variation of the principal components of each subcarrier. Notably, the first principal component varied significantly. The best subcarrier was available for extraction in each sample and was selected for subsequent feature extraction. Data Smoothing. For sample data x, each side of the data was taken with a sliding window length of 2, and the median value within the window is expressed as follows:  
After selecting the best subcarrier by using the PCA method, due to the sensitivity of CSI to environmental changes and despite the removal of high-frequency noise via wavelet transform, some noise was still present due to the perturbation of the data caused by the environment during data transmission. To remove this subtle noise interference and to make the subsequent classifier learning more accurate, data smoothing was performed by dividing it into moving average and exponential smoothing algorithms. The moving average smoothing algorithm collects observations and calculates the mean value of the set of observations, whereby the mean value is used as the next prediction value. Before calculating the moving average smoothing algorithm, the actual number of past observations must be determined, and each time a new observation appears, the earliest observation is subtracted and the moving average is calculated. The new moving average is used as the forecast value for the next period. Let the time series be \(y_{1}\), \(y_{2}\ldots y_{t}\). The formula of moving average algorithm is presented below:  
\[F_{t}^{(1)}=\frac{y_{t}+y_{t-1}+\ldots+y_{t-n-1}}{n} \tag{9}\]  
where \(n\) is the moving interval and \(F_{t}^{(1)}\) is the moving average at \(t\) interval. The moving average method has the advantage of being less computational and better reflects both the trend and the change of amplitude information. The essence of the exponential-based data smoothing algorithm is the weighted moving average method, which differs from the moving average data smoothing algorithm, as the former algorithm assigns different weights to different observations using the formula below:  
\[S_{t}^{(1)}=\mu y_{t}+(1-\mu)S_{t-1}^{(1)} \tag{10}\]  
where \(S_{t}\) is the predicted value at moment \(t\), and \(\mu\) is the smoothing factor. Although the implementation of exponential-based data smoothing algorithm is relatively simple, it needs to find the best value. To achieve this, it must be calculated repeatedly via experiments.