# Emotional State Detection Using Electroencephalogram Signals: A Genetic Algorithm Approach
## 2 Materials and Methods
### Feature Selection  
The database used to carry out this work included 2548 statistical and time-dependent features to describe three mental states. All these features may have the potential to include important information to describe part of the emotional state classification problem; however, this might be computationally costly. The genetic algorithm introduced by [PERSON] and [PERSON] [30] is based on the natural selection mechanism. The algorithm's objective is to discover the best solution for chromosome survival, with a statistical optimization approach. Genetic algorithms are based on natural behavior.  
There are different types of GAs; some authors classify the variants into five main categories: real- and binary-coded, multi-objective, parallel, chaotic and hybrid [18]. The type of GA used in this study is a multi-objective statistical model-building approach with a specific search strategy for variable selection. The general operation of the GA is based on the random creation of a population called (Y) of n chromosomes; the fitness of each chromosome in the population is evaluated, according to this evaluation two chromosomes, C1 and C2 are selected, and a crossover operator with crossover probability (Cp) is applied to those chromosomes C1 and C2 to produce an offspring, O. Then, a mutation operator with mutation probability (Mp) is applied on the offspring O to generate O\({}^{\prime}\). Finally, the offspring O\({}^{\prime}\) is placed in the new population. From here, the selection, crossover and mutation operations are repeated iteratively until the new population is complete. Figure 2 represents the GA flow chart with the following listed steps:  
* Step 1: creation of a random initial population of chromosomes, which in this case are sets of 5 genes or features.
* Step 2: consisting in the evaluation of the capability of the chromosomes to predict the different emotional states, with this creating a statistical model, the GA assigns a score to each chromosome, and this score is proportional to the resulting accuracy of the model. In this study, the nearest centroid classifier is used in the model.
* Step 3: if the score in the previous step is higher than that of the defined fitness goal, the chromosome is selected; if it is not, the process continues.
* Step 4: the chromosomes best suited to the problem are replicated; the higher the score, the bigger the offspring.
* Step 5: the crossover consists of a recombination of pairs of good chromosomes from the genetic information of the replicated parents.
* Step 6: the mutations created in Step 5 are now included in the new population, allowing new genes to be included in the chromosomes.
* Step 7: the process is repeated from Step 2 onwards until a solution is found; each cycle from Step 4 to Step 6 is referred to as a generation.  
In this study, an R package named GALGO is used [30; 31].  
Table 1 describes the parameters selected for the GALGO analysis. The classification method selected was nearest centroid, which is a very simple and fast classifier capable of classifying data without feature selection and is also computationally inexpensive.  
\begin{table}
\begin{tabular}{l l} \hline \hline
**Parameter** & **Value** \\ \hline Classification method & \multicolumn{1}{l}{Nearcent} \\ Chromosome size & 5 \\ Solutions & 4000 \\ Generations & 200 \\ Goal fitness & 1 \\ \hline \hline \end{tabular}
\end{table}
Table 1: GALGO parameters.