## 2 Materials and Methods
### Handling Class Imbalances
9:- Perform ROCKET on each segment of \(Acc^{j}_{t,k^{\prime}},t\in\{x,y,z\}\), \(ST^{j}_{k^{\prime}}\), \(GSR^{j}_{tonic,k^{\prime}}\), \(GSR^{j}_{phasic,k^{\prime}}\)\(BVP^{j}_{k}\)
10:- Perform power spectral subtraction by using Equation (3)
11:- Extract the frequency, height, width, and the prominence from artifact-free segments \(N_{BVP\perp Acc_{t}}\)
12:- Augment feature extracted from the power spectrum \(N_{BVP\perp Acc_{t}}\) to features extracted by ROCKET
13:endfor
14:- Stack each 5 consecutive segmented of features to construct the tensor of input data
15:- For each subject, stack 3D tensor of features to the rest of tensors of features from other datasets
16:endfor
17:- Randomly exclude sessions(labels) different subjects from the stack of the data to split the tensor of input features and target variables into training, validation, and test split
18:- For each one of target variables, perform PCA to select top 200 most informative features
19:- Perform SFS and PLS-DA on each target variable to select top 200 most informative features. 20:- Narrow down the number of selected features from SFS and PLS-DA by keeping mutual features in each pair of target variables
21:



variation of biosignals during different clinical sessions was significantly different. Then, to address imbalanced classes in the training set, we resized each class using the approaches discussed in the previous section. Table 4 summarizes the sizes of the different labels in the training splits of four datasets. In order to better compare the performance of the RNN models in predicting class labels of different classification problems, we used the balanced accuracy score (Equation (4)):

\[balAcc=\frac{\sum_{i=1}^{n}Specificity_{i}+Sensitivity_{i}}{2n} \tag{4}\] \[Sensitivity=\frac{\sum TP}{\sum TP+\sum FN}\] \[Specificity=\frac{\sum TN}{\sum TN+\sum FP}\]

Balanced accuracy score is the proper metric for coping with fallacious interpretation of imbalance classes in the data [66; 67; 68]. The balanced accuracy score and number of misclassified samples are reported in Tables 5-8. All numerical studies were conducted in the TensorFlow 2.0 environment, and several other Python libraries were used for data preprocessing [40; 65; 69; 70; 71]. \begin{table}
\begin{tabular}{l c c c c} \hline \hline \multicolumn{5}{c}{**The size each class in training split for different types of APS inducement**} \\ \hline  & Upsampling & Downsampling & ADASYN & Initial Size \\ \hline Non-Stress & 101,339 & 21,111 & 100,121 & 23,631 \\ Emotional Anxiety Stress & 101,339 & 21,111 & 101,339 & 101,339 \\ Mental Stress & 101,339 & 21,111 & 100,574 & 21,111 \\ \hline \multicolumn{5}{c}{**The size each class in training split for different types of exercise equipment**} \\ \hline  & Upsampling & Downsampling & ADASYN & Initial Size \\ \hline Sedentary State & 122,660 & 11,150 & 122,660 & 122,660 \\ Stationary Bike & 122,660 & 11,150 & 123224 & 11,150 \\ Treadmill Run & 122,660 & 11,150 & 122,617 & 11,174 \\ \hline \multicolumn{5}{c}{**The size each class in training split for different types of PA**} \\ \hline  & Upsampling & Downsampling & ADASYN & Initial Size \\ \hline Sedentary State & 122,661 & 5022 & 12,2661 & 12,2661 \\ Aerobic Exercise & 122,661 & 5022 & 122,489 & 18,407 \\ Anaerobic Exercise & 122,661 & 5022 & 122,596 & 5022 \\ \hline \multicolumn{5}{c}{**The size each class in training split for jointly estimation of PA and APS inducement**} \\ \hline  & Upsampling & Downsampling & ADASYN & Initial Size \\ \hline Sedentary State\& Non-Stress & 111,792 & 10,659 & 111,822 & 10,860 \\ \hline Sedentary State\& & & & \\ (Mental Stress or Emotional Anxiety Stress) & 111,792 & 10,659 & 111,792 & 111,792 \\ \hline (Aerobic Exercise or Anaerobic Exercise) \& & & & \\ (Aerobic Exercise) \& & & & \\ (Aerobic Exercise) \& & & & \\ (Mental Stress or Emotional Anxiety Stress) & & & & \\ \hline \hline \end{tabular}
\end{table} 
Table 4: The size of the training splits after applying different techniques for balancing the training split of the data.