# A CSI-Based Multi-Environment Human Activity Recognition Framework
## 3 Results
### Data Preparation
#### 3.1.1 Initial Preprocessing Stage  
For each of the recorded signals, we removed the outliers using the Hampel filter with a window size of 32 data points, equivalent to 0.1 s since the transmitter is sending packets at a rate of 320 packets/second.  
Once the outliers have been removed, we transform the acquired non-stationary signals into stationary signals by using the differencing procedure outlined in the \"Initial Preprocessing\" Section. To determine the stationarity of the signals, we selected some sample signals and tested them before and after the differencing process. Figure 10 shows a sample signal before and after applying the differencing procedure.  
Figure 10 shows that the ADF test value before the test was equal to 0.388, which means that the signal is a non-stationary signal. After differencing the signal, the ADF test value is reduced to 0.001, which means a stationary signal is now available.  
Once a stationary signal has been acquired, we reduced the dimensionality of the available data by using the PCA algorithm. The PCA algorithm takes as input the gathered CSI sub-carriers and generates several PCA components. To determine the appropriate number of principal components to use, we relied on two metrics:  
* The variance in the principal components. For this metric, we calculated the variance of the data in each of the principal components. Figure 11 shows the variance contained in each of the principal components generated from the first stream of the office environment. It shows no meaning in using all the principal components since there is no data variance in the components above the 10 th component. We found out that 98% of the data variance is contained in the first eight principal components.
* The error in activity segmentation. For this metric, we performed the segmentation procedure using various principal component combinations. We started with four components and stopped when we reached 15 components since most of the data are contained in the earliest components. The segmentation algorithm may lead to a segmentation error if it cannot determine the segment's starting or ending points. This  
Figure 11: The variance in each PCA components.  
Figure 10: The effect of differencing on the ADF test.  
latter condition is used as a metric to determine how many principal components to use. Figure 12 shows the percentage of recorded activities that the segmentation algorithm was unable to extract a segment from. If we selected eight principal components, as the first evidence suggested, only 1% of the activities will not be segmented successfully. Such errors will be handled after the segmentation procedure as described in the \"segmentation\" Section.  
Based on the two metrics discussed before, we decided to use eight principal components as inputs to the segmentation process. They contain most of the information and produce reasonable segmentation errors compared to the work needed if more principal components were added.  
The last data transformation we performed before the segmentation process was to smooth the signals. We used a Gaussian smoothing function with a window size of 48 points, which is equal to 0.15 s since the frequency by which packets arrive at the receiver is 320 packets/second. Figure 13 shows the effect of applying the smoothing function on the recorded signal.