# Detection and Characterization of Physical Activity and Psychological Stress from Wristband Data
## 2 Materials and Methods
### Feature Extraction and Dimensionality Reduction  
A total of 866 primary features were extracted from the five biosignals measured by the wristband device. The features were generated from each one-minute epoch of data. We generated statistical and mathematical features for each variable, including mean, standard deviation, median, quartiles, mean-of-squared values, maximum, minimum, range, slope, first derivative, second derivative, ratio of maximum to minimum values, sum of absolute values, mean of absolute values, interquartile range, coefficient of variation, autoregressive parameters, wavelet decomposition coefficients, signal-to-noise ratio (SNR), skewness, kurtosis, correlations between biosignals, mean normalized frequency, power, magnitude of frequency response, and Fourier transform(Figure 7 and (Table 3)) [11]. These features constitute the primary features and were computed for each variable, yielding 866 primary features. The secondary features were computed as the ratio of primary features from two different biosignals, which yielded 1350 secondary features. The illustration of 10 different commonly-used extracted features from GSR measurements is presented Figure 7. Since the denoised BVP signal significantly eliminates motion artifacts and provides peaks that are accurate (Figure 6), the denoised BVP values were used in feature extraction. Secondary features were obtained by the ratio of primary features to each other, which can indicate some physiological and psychological states. For example, the ratio of ACC to GSR can be useful in discriminating APS from PA because GSR increases during APS while ACC measurements maintains the same level. Finally, 2216 different features were obtained by combining the primary and secondary features. Features were normalized to give each feature variable an equal weight, and principal component analysis (PCA) and partial least squares (PLS) were conducted for feature dimension reduction [56]. The same pool of feature variables was used for PS classification and EE estimation (Table 4). Most of the extracted features are highly correlated with each other (such as median of HR and mean of HR). Highly correlated features do not provide additional information for ML algorithms, and their use may add bias to similar attributes, leading to poor estimation and classification accuracy. PCA is used to reduce the dimensionality of extracted features [57]. This facilitates reducing the number of variables used for training the models, resulting in principal components being retained that capture the informative variation from the feature variables to avoid the risk of overfitting. The first 275 principal components were used as the inputs of each ML algorithm. We varied the number of principal components that were retained when building the models while observing the accuracy of a validation data set. Our analysis showed that retaining 275 principal components resulted in the highest accuracy. Increasing the number of principal components beyond 275 resulted in no improvement in classification accuracy, but the computational requirements increased due to the largernumber of inputs to the models. For EE estimation, PLS regression was used to reduce the features to a smaller set of latent variables that are most correlated with the EE. Due to the lack of physical exertion, the SS experiments were longer in duration than the other experiments, which caused an imbalance among the classes. Since imbalances in class sizes may result in bias and poor classification accuracy, a combination of up-sampling (adaptive synthetic sampling (ADASYN) [58]) and down-sampling methods were used. The impact of upsampling the minor class is reduced by simultaneously downsampling the major class by retaining the unique samples as determined by the similarity measure of k-means clustering. We also studied the effect of different levels of upsampling the minor class on the accuracy of the physical state and acute psychological stress classification results.