<jupyter_start><jupyter_text>Tutorial: Hand gesture classification with EMG data using Riemannian metrics In this notebook we are using EMG time series collected by 8 electrodes placed on the arm skin. We are going to show how to - Process these kind of signal into covariance matrices that we can manipulate with geomstats tools.- How to apply ML algorithms on this data to classify four different hand gestures present in the data (Rock, Paper, Scissors, Ok).- How do the different methods (using Riemanian metrics, projecting on tangent space, Euclidean metric) compare to each other.   ContextThe data are acquired from somOS-interface: an sEMG armband that allows you to interact via bluetooth with an Android smartphone (you can contact <NAME> (<EMAIL>) or <NAME> (<EMAIL>) for more info on how to make this kind of armband yourself). An example of application is to record static signs that are linked with different actions (moving a cursor and clicking, sign recognition for command based personal assistants, ...). In these experiments, we want to evaluate the difference in performance (measured as the accuracy of sign recognition) between three different real life situations where we change the conditions of training (when user record signs or "calibrate" the device) and testing (when the app guess what sign the user is doing):- 1. What is the accuracy when doing sign recognition right after training?- 2. What is the accuracy when calibrating, removing and replacing the armband at the same position and then testing? - 3. What is the accuracy when calibrating, removing the armband and giving it to someone else that is testing it without calibration?To simulate these situations, we record data from two different users (rr and mg) and in two different sessions (s1 or s2). The user put the bracelet before every session and remove it after every session.Quick description of the data:- Each row corresponds to one acquisition, there is an acquisition every ~4 ms for 8 electrodes which correspond to a 250Hz acquisition rate.- The time column is in ms.- The columns c0 to c7 correspond to the electrical value recorded at each of the 8 electrodes (arbitrary unit).- The label correspond to the sign being recorded by the user at this time point ('rest', 'rock', 'paper', 'scissors', or 'ok). 'rest' correspond to a rested arm.- the exp identify the user (rr and mg) and the session (s1 or s2)Note: Another interesting use case, not explored in this notebook, would be to test what is the accruacy when calibrating, removing the armband and giving it to someone else that is calibrating it on its own arm before testing it. The idea being that transfer learning might help getting better results (or faster calibration) than calibrating on one user.  Useful Packages<jupyter_code>import matplotlib
matplotlib.interactive(True)
import matplotlib.pyplot as plt<jupyter_output><empty_output><jupyter_text>Setup Before starting this tutorial, we set the working directory to be the root of the geomstats repository. In order to have the code working on your machine, you need to change this path to the path of your geomstats repository.<jupyter_code>import os
import subprocess

geomstats_gitroot_path = subprocess.check_output(
    ['git', 'rev-parse', '--show-toplevel'], 
    universal_newlines=True)

os.chdir(geomstats_gitroot_path[:-1])

print('Working directory: ', os.getcwd())<jupyter_output>Working directory:  /home/marius/proj/geomstats<jupyter_text>Parameters<jupyter_code>N_ELECTRODES = 8<jupyter_output><empty_output><jupyter_text>The Data<jupyter_code>import geomstats.datasets.utils as data_utils

data = data_utils.load_emg()
data.head()
fig, ax = plt.subplots(4, figsize=(20, 20))
label_list = ['rock', 'scissors', 'paper', 'ok']
for i, label_i in enumerate(label_list):
    sign_df = data[data.label==label_i].iloc[:100]
    for electrode in range(N_ELECTRODES):
        ax[i].plot(sign_df.iloc[:, 1 + electrode])
        ax[i].title.set_text(label_i)<jupyter_output><empty_output>
{'fraction_non_alphanumeric': 0.0654391639711371, 'fraction_numerical': 0.006718089076884797, 'mean_word_length': 5.137404580152672, 'pattern_counts': {'":': 0, '<': 20, '<?xml version=': 0, '>': 20, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'chain_length': '4', 'dir': 'jupyter-structured-clean-dedup', 'id': '281601', 'license': 'MIT', 'n_tokens_mistral': 1104, 'n_tokens_neox': 1040, 'n_words': 543, 'path': 'notebooks/07_emg_hand_gesture_classification.ipynb', 'repo_name': 'ythanwerdas/geomstats', 'size': '4076'}