# SVSL: A Human Activity Recognition Method Using Soft-Voting and Self-Learning
## 3 Methodology
### Proposed Method  
HAR is a problem of great interest due to its wide array of applications, including healthcare, surveillance, adaptive content delivery, tracking, etc. Machine learning is at the forefront of it. We called our HAR method Soft-Voting and Self-Learning (SVSL). The idea is to use the power of combined decision-making rather than limiting it to a single classifier. For this purpose, we used soft voting, where we combined the prediction probabilities and took weighted probability as the deciding factor in SVSL.  
Further, to enhance the prediction accuracy, the SVSL method was integrated with a self-training mechanism. By self-training mechanism, we mean that the SVSL method trains itself again periodically, without the need for any data from the user side and any human interference. We believe that this trick could help us understand and correctly classify the data instances that are the most difficult to predict and efficiently accommodate dynamic environments. A functional block diagram of the SVSL method is shown in Figure 1, and the self-training process is shown in Figure 2. Further, for an in-depth understanding, the Algorithm 1, is given, which is self-explanatory.  
The SVSL works in two phases: (1) Soft-voting and (2) Self-training phases. Figure 1 depicts the processing steps of the SVSL method. First, we divided the dataset into training and test data by 0.7 and 0.3 ratios. First, DL, GLM, RF are trained separately. For DL, Tanh is used as an activation function. Figure 3 depicts that the model with 40 epochs and two hidden layers with 64 neurons each produced the best training results. Hence the model with these parameters is selected from the eight trained DL models.  
Then, using soft-voting, we obtained the final model (\(Final_{model}\)) using the formulation of soft-voting given in Equations (1)-(4), where the activity class is denoted by \(i\) = (Walking; Standing, etc.), the predicted class probabilities are denoted by \(\rho\), and the classifiers used for voting are denoted by \(j\ \gets RF_{p},\ GLM_{p},\ DL_{p}\).  
\[p(i_{1}|x)\ \leftarrow\ \frac{RF_{p_{1}}+GLM_{p_{1}}+DL_{p_{1}}}{3} \tag{1}\]\[p(i_{2}|x) \leftarrow \frac{RF_{p_{2}}+GLM_{p_{2}}+DL_{i_{2}}}{3} \tag{2}\] \[p(i_{n}|x) \leftarrow \frac{RF_{p_{n}}+GLM_{p_{n}}+DL_{p_{n}}}{3}\] (3) \[\text{\emph{Labels}} \leftarrow \text{\emph{argmax}}\sum_{j=1}^{m}w_{i}p_{ij} \tag{4}\]  
Figure 1: Workflow of the SVSL method.  
Figure 2: Self-training mechanism of the SVSL method.  
Once the \(Final_{model}\) is obtained, as given in Figure 1 and further in Algorithm 1, we use it to predict the activity class. \(Final_{model}\) is trained periodically from a buffered dataset, which is obtained autonomously from the predicted data. Buffered data are the saved data from the previous ten predictions from \(Final_{model}\), which is updated periodically. The periodically trained model is used to predict human activity labels. Figure 2 depicts the self-training process, which is an iterative task. After every ten executions, \(Final_{model}\) is replaced by the retained \(Final_{model}\).  
```
# Enter independent variables
1. Input Data: d
# Predicted Activity Label
2. Result: L
3. Begin
# Predicted activity labels with RF, GLM, and DL trained models
4. RF \(\leftarrow\) RF(d), GLM \(\leftarrow\) GLM(d), DL \(\leftarrow\) DL(d)
# Use Soft Voting function to combine predicted probabilities
# Obtain Final model and prediction
5. Final\({}_{\text{model}}\)\(\leftarrow\)\(\text{s}_{\text{vote}}(\text{RF}_{\text{d}}\), GLM\({}_{\text{d}}\), DL\({}_{\text{d}})\)
6. End\({}_{\text{model}}\)
# Self-Train periodically with buffer datasets
7. RF\({}_{\text{d}}\)\(\leftarrow\) RF(d\({}_{\text{buffer}}\)), GLM\({}_{\text{d}}\)\(\leftarrow\) GLM(d\({}_{\text{buffer}}\)), DL\({}_{\text{d}}\)\(\leftarrow\) DL(d\({}_{\text{buffer}}\))
8. Update models at Step 4
9. Move to Step 5 and repeat whole process again
```  
**Algorithm 1** SVSL Method