# Emotional State Detection Using Electroencephalogram Signals: A Genetic Algorithm Approach
## 3 Results  
With the results of the GA analysis in the R software (Version 3.6.3), Figure 5 shows the fitness scores over generations; the ordinate axis indicates the fitness score, and the abscissa axis represents the generations. This graph represents the chromosomes' capacity to accurately detect each emotional state, with the blue line indicating all models' mean fitness. As can be deduced from Figure 5, after 150 generations, there was no appreciable change in the fitness score, demonstrating that the previously established value of 200 was congruent. \begin{table}
\begin{tabular}{c c c} \hline \hline  & **Actually Positive** & **Actually Negative** \\ \hline Predicted Positive & True positives (TP) & False positives (FP) \\ Predicted Negative & False negatives (FN) & True negatives (TN) \\ \hline \hline \end{tabular}
\end{table} 
Table 2: Confusion matrix. Figure 4: Structure of an artificial neural network. Figure 6 showing the Gene Rank Stability graph displays the ranked stability of the genes showing the stability of the features in the models in order. The first features are the most stable and their color is solid, which means these features contribute more to the classification. After ranking the most significant features, the forward selection method outputs 49 features, as shown in Figure 7. The ordinate axis indicates the accuracy in terms of classification, and the abscissa axis presents the features in order of importance, while the  
Figure 5: Fitness scores over generations. Figure 6: Gene rank stability. Graph shows the genes in order of importance from left to right according to the frequency of occurrence in the solutions, but also in order of stability, which is defined by the amount of rank changes they suffered through the evaluation of all solutions. This rank change is represented in the graph by colors; if the genes had many rank changes, the graph shows a mixture of colors. Specifically, the darker tones such as black and red tones represent the most stable genes, which stabilized over a few hundred solutions, while the genes indicated by light tones such as gray and yellow tones required thousands of solutions to stabilize. black line is the best-performing model which in this case is model number 23 with an accuracy of 0.9019. With regard to this, it could be said that the 49 features listed in Table 3 include important information from the EEG signal with which to classify the emotional states, and this represent a 98% reduction in the total number of features. Figure 8 shows the data distribution related to each emotional state from the 49 selected features. \begin{table}
\begin{tabular}{c} \hline \hline
**Model 23’s Features** \\ \hline “mean\_0 b”, “mean\_0 a”, “stddev\_2 a”, “stddev\_2 b”, “min\_q\_7 b”, “mean\_3 b”, “min\_q\_7 a”, “min\_q\_17 a”, “mean\_3 a”, “min\_q\_17 b”, “logm\_8 a”, “logm\_8 b”, “min\_2 a”, “min\_q\_12 a”, “min\_q\_2 a”, “min\_q\_2 b”, “min\_2 b”, “mean\_d\_5 a”, “min\_q\_12 b”, “mean\_d\_5 b”, “mean\_d\_15 a”, “logm\_9 a”, “mean\_2 b”, “mean\_d\_15 b”, “max\_1 a”, “logm\_9 b”, “mean\_d\_10 b”, “mean\_d\_17 b”, “mean\_d\_8 a”, “mean\_d\_0 b2”, “mean\_d\_7 a”, “mean\_2 a”, “max\_1 b”, “mean\_d\_8 b”, “mean\_d\_2 b2”, “mean\_d\_2 a”, “mean\_d\_10 a”, “mean\_d\_18 a”, “mean\_d\_12 b”, “mean\_d\_17 a”, “min\_q\_5 b”, “min\_q\_15 a”, “mean\_d\_7 b”, “mean\_d\_12 a”, “mean\_d\_18 b”, “min\_q\_15 b”, “max\_q\_16 a”, “max\_q\_6 b”, “max\_q\_1 b”. \\ \hline \hline \end{tabular}
\end{table} 
Table 3: Resulting features. Figure 7: Models Average Fitness from the forward selection method. With the 49 features selected within the best-accuracy model during the genetic algorithm's implementation, the performance of three machine learning methods was assessed for the prediction of the negative, neutral, and positive emotional states in the test proportion of the data. The algorithms used are; KNN, RF and ANN. Table 4 show the Overall accuracy of the three models. The results have shown a higher overall accuracy of ANN model over KNN and RF.