# LSTM Recurrent Neural Network for Hand Gesture Recognition Using EMG Signals
## 2 Methodology
### Experimental Validation  
In order to analyze and evaluate the proposed model two main phases were performed. An initial phase where the model was trained and tuned according to the concepts mentioned in Section 2.4; and a second phase where the best performing models of the first phase, were tested in real time gesture classification. Both experimental stages validated the model performance using the metrics seen in Section 2.5.  
In the first phase, training and tuning, the training/validation data-set was constructed as mentioned in the experimental set-up (Section 2.1. Once the data sets were formed, the next step was to train and tune the model, for this, a hyper-parameter tuning process was performed (Section 2.4.1). In this process, a total of six different LSTM-RNN architectures were proposed following the general architecture presented in Section 2.3; in this part, the LSTM-RNN architecture was increased in size in each one of the models, the first three proposed model consisted in only one LSTM layer and the last three were hybrid models composed of Dense and LSTM layers; this was done in order to increase the size of the network gradually until an optimal performance architecture was found, aiming to find a good trade off between model size and performance; this trade off is a key part to embedding the model into a micro-controller in the future. During the hyper-parameter tuning, a manual search was used to set the learning rate \(\alpha\), the batch size and the number of training epochs. In this first stage, the trained models were evaluated with the metrics proposed in Section 2.5. For a model to be considered for the second phase (real time validation), it was required that it had a training accuracy \(\geq\)98% as well as a training F1-Score \(\geq\)98%; the model must also hve a difference \(\leq\)1% between training and validation for both the accuracy and F1-Score in order for it to not suffer from high variance.  
In a second phase, a real time validation was carried out. This validation is a fundamental step, because it allows to identify flaws in the gesture recognition system and measure the performance of the model dynamically. To tackle this, the candidate LSTM-RNN models selected in the previous phase were evaluated in four sessions using real time EMG acquisition using the EMG armband, in this sessions each gesture was performed for 20 s. Taking into consideration the possible reduction in accuracy due to changes in the EMG armband position, thus, changes in the data distribution, the candidate models (pre-trained) were re-trained after the initial training phase using data of another two EMG recording sessions, where the EMG armband was taken off and put back on the arm between sessions. Each session the EMG armband was put approximately in the same position; this was done in order to take into account the variations in data distribution due to the small changes in the EMG armband position.  
For this last phase, the re-trained models were evaluated using the metrics proposed in Section 2.5. In this phase, one of the candidate models was selected as the final LSTM-RNN gesture classifier. The conditions for the selection of this model were that it had an accuracy and F1-Score \(\geq\) 80%. It is important to note that the real time target metrics are lower compared to the training/validation targets, because in this phase the sensitivity of the EMG acquisition armband and its position on the arm, which varies across different real time recording sessions, are variables that have an impact on the performance of the algorithm [40; 77; 78; 79].