||Rock, Paper or Scissor Game - Train and Classify [Volume 1]|
Machine Learning is a very suggestive term to define this scientific area and the "result" of their algorithms. "Machine Learning grew out of the quest for artificial intelligence" , which inspires many people in building a totally new world with endless possibilities.
In fact, only the idea of creating an intelligent system (even artificially) is both amazing and scaring, like all the ideas and discoveries which allowed to overcome a barrier that was previously considered as immutable.
In a very generic and simplistic way, Machine Learning includes the tools (algorithms) that computers can use in order to learn and acquire knowledge based on examples. The process that causes the acquisition of knowledge is called "Training" and it can happen in a supervised or unsupervised paradigm.
The main difference between the "supervised" and "unsupervised" training processes reside in the labeling of training examples, i.e., in the supervised learning algorithms the user reveals to the algorithm the class of each training example, which does not happen on the "unsupervised" case.
After the training stage the mathematical model that supports the algorithm should have their parameters optimized and is ready to return an adequate result/class when it receives new examples to classify.
Following this concepts biosignalsnotebooks contains a Notebook divided into 4 volumes covering all the procedure behind training and classification of a "Nearest Neighbor" classifier that will be able to distinguish between 3 possible hand gestures, using electromyographic data from two muscles and accelerometer data from one axis.
Like previously referred, for a system to make a decision we should be able to provide example data from where classification can be learned and provided. Imagine creating a game that using the signals from your hand can try to guess what is the gesture you are making and play "Rock, Paper or Scissor" game.
|☌ In the current Jupyter Notebook it will be explained which conditions were used to acquire the training data.|
Starting Point (Setup)List of Available Classes:
1 - Placement of EMG electrodes for monitoring muscular activity
1.1 - Placement of electrodes for monitoring muscular activity of Adductor pollicis
1.2 - Placement of electrodes for monitoring muscular activity of Flexor digitorum superficialis
1.3 - Selection of a bone structure away from the active muscles (in our case the clavicle was used)
|Adductor pollicis||Flexor digitorum superficialis||Ground electrode on clavicle|
2 - Fixation of accelerometer to the nail of the thumb
3 - Start of signal acquisition procedure
3.1 - Execute OpenSignals software
3.2 - Access the "Device Configuration" screenAt this stage it should be activated the three needed channels ( CH1 Flexor digitorum superficialis | CH2 Adductor policis | CH3 Accelerometer axis Z).
3.3 - Start signal acquisition/recording procedure, taking into consideration the experimental protocol described below
It is all ready for collecting some training data !!!
The experimental protocol is divided into 4 parts (1/available class). For each class we gathered EMG and ACC data for 5 times (trials).
So, at the final we have 20 training examples (5/available class).
Graphical Representation of the Acquired DataOne representative trial of each class is presented below !
Class "No Action"
import biosignalsnotebooks as bsnb import numpy # Specification of constants sr = 1000 # Hz # Load of data ["No Action"] no_action_signals = bsnb.load("/signal_samples/classification_game/data/0_5.txt") emg_ch1 = no_action_signals["CH1"] emg_ch2 = no_action_signals["CH2"] acc_ch3 = no_action_signals["CH3"] # Generation of time-axis. time_axis = numpy.linspace(0, len(emg_ch1) / sr, len(emg_ch1)) # Plot of data bsnb.plot([time_axis, time_axis, time_axis], [emg_ch1, emg_ch2, acc_ch3], grid_plot=True, grid_lines=1, grid_columns=3, title=["EMG | Flexor digitorum superficialis", "EMG | Aductor policis", "ACC | Axis Z"])
# Specification of constants sr = 1000 # Hz # Load of data ["No Action"] no_action_signals = bsnb.load("/signal_samples/classification_game/data/1_5.txt") emg_ch1 = no_action_signals["CH1"] emg_ch2 = no_action_signals["CH2"] acc_ch3 = no_action_signals["CH3"] # Generation of time-axis. time_axis = numpy.linspace(0, len(emg_ch1) / sr, len(emg_ch1)) # Plot of data bsnb.plot([time_axis, time_axis, time_axis], [emg_ch1, emg_ch2, acc_ch3], grid_plot=True, grid_lines=1, grid_columns=3, title=["EMG | Flexor digitorum superficialis", "EMG | Aductor policis", "ACC | Axis Z"])