OPEN ACCESS ISSN 2356-5462 http://socj. id/ijoict/ Intl. Journal on ICT Vol. No. Jun 2024. doi: doi. org/10. 21108/ijoict. Optimizing Hyperparameters of Convolutional Neural Network and Deep Neural Network for Emotion Classification Based on EEG Signals Dian Palupi Rini*. Winda Kurnia Sari. Novi Yusliani. Pita Rosmeri Faculty of Computer Science. Universitas Sriwijaya Jl. Palembang-Prabumulih KM. 32 Inderalaya Ogan Ilir * dprini@unsri. Abstract This study addresses the optimization of Convolutional Neural Network (CNN) and Deep Neural Network (DNN) hyperparameters for EEG emotion signal classification, a pivotal area in emotion classification systems. The dataset is divided into three ratios: 80:20, 70:30, and 60:40, with subsequent hyperparameter tuning. CNN achieves a peak accuracy of 98. 36%, while DNN attains 18%, both in the 80:20 scenario. Notably, differences in loss curves reveal the nuanced performance complexities of both models. The 80:20 data split proves most impactful, outperforming the 70:30 and 60:40 splits. The choice of employing both DNN and CNN stems from their complementary strengths. CNN excels in spatial feature extraction, suited for multidimensional EEG signals, while DNN proficiency lies in learning hierarchical representations for discerning intricate patterns in temporal EEG data. Integrating both architectures aim to harness their combined strengths, enhancing the robustness of the EEG emotion classification system. Keywords: EEG Emotion. Optimizing. Hyperparameter. CNN. DNN. Deep Learning INTRODUCTION lectroencephalogram Emotion, or EEG Emotion for short, is a neurological study that monitors human brain activity to identify and understand emotional changes. In this research, participants perform tasks or express emotions while being recorded with EEG. This data is used to recognize patterns of brain activity associated with various types of emotions . This research has many applications in psychology, humancomputer interfaces, mental health, and the development of emotion technology, such as recognizing emotions in autonomous car drivers or assisting individuals with emotional disorders . On the other hand, optimizing hyperparameters in machine learning models, such as Convolutional Neural Networks (CNN) and Deep Neural Networks (DNN), plays a crucial role in addressing challenges in processing EEG Emotion data. Careful tuning of hyperparameters not only improves model performance and accuracy but also minimizes the risk of overfitting and underfitting, which has a significant impact on the model's ability to generalize well on unseen data . Furthermore, through hyperparameter optimization, we can produce computationally efficient models that can better adapt to the specific characteristics of EEG-based emotion Received on 14 Oct 2023. Revised on 26 Jan 2024. Accepted and Published on 30 Jun 2024. DIAN PALUPI RINI ET AL. OPTIMIZING HYPERPARAMETERS OF CONVOLUTIONAL NEURAL NETWORK AND DEEP NEURAL NETWORK FOR EMOTION classification problems . In this way. EEG Emotion technology can have a positive impact in various application fields, including healthcare, automation, and data analysis. Recent research in the development of classification models for emotion recognition based on EEG signals using deep learning has revealed the significant potential of Convolutional Neural Networks (CNN) . in extracting crucial spatial features from EEG data. Recurrent Neural Networks (RNN) such as Long Short-Term Memory (LSTM) . and Gated Recurrent Unit (GRU) . in handling temporal signals that change over time, and Deep Neural Networks . in general in integrating information from various levels of abstraction. All of these provide a diversity of approaches and techniques that can be employed to enhance accuracy and reliability in classifying emotions based on EEG data, which is becoming increasingly important across various The advantage of deep learning in EEG emotion classification lies in its ability to automatically extract relevant features from complex EEG data and model more abstract relationships between these signals . This enables deep learning to improve emotion classification accuracy to a higher level than traditional methods and address the challenges posed by high-dimensional EEG data containing intricate patterns. In the face of challenges in emotion recognition based on EEG signals, this research primarily aims to enhance the performance of Convolutional Neural Networks (CNN) and Deep Neural Networks (DNN) in emotion classification by optimizing key parameters. The research primarily focuses on the parameter tuning phase of these CNN and DNN models. Through meticulous adjustment of these crucial parameters, it is expected to yield more precise models in identifying brain activity patterns associated with various human emotions. This research not only has implications for understanding human emotions through EEG data analysis but also in improving technology's ability to recognize and respond to emotions in various contexts, such as humanmachine interfaces and applications in mental health. II. LITERATURE REVIEW In the study conducted by . , the focus was on EEG-based emotion detection using publicly available data, employing a newly proposed method to recognize inner emotional states. In this endeavor, a supervised machine learning algorithm was specifically designed to identify various inner emotional states in a two-dimensional Electroencephalography (EEG) data were obtained from the DEAP and SEED-IV databases for the purpose of emotion detection. Prior to this. EEG signals had been preprocessed and subjected to Discrete Wavelet Transform to extract five relevant frequency bands. Various features such as power, energy, differential entropy, and time domain were extracted for further analysis. A channel-based SVM classifier was employed, and channel fusion was performed to detect the corresponding emotional states. The research results indicated classification rates of 74%, 86%, 72%, and 84% for four classes in the DEAP database, while the classification rates for the SEED-IV database were 79%, 76%, 77%, and 74%. These findings provide valuable insights into emotion recognition through EEG data using a machine learning approach. In order to identify EEG signals, this study . adopted the Discrete Wavelet Transform as well as machine learning techniques such as Recurrent Neural Networks (RNN) and k-Nearest Neighbor . NN) algorithm. Initially, a channel selection method was used to make decisions. As a result, a final feature vector was constructed by integrating EEG segment features from these channels. Through the utilization of RNN and kNN algorithms, the final feature vectors associated with positive, neutral, and negative emotions were independently The performance of both classification techniques was calculated and compared. By using RNN and kNN, the average overall accuracy of each was 94. 844% and 93. 438%, respectively. This indicates that both methods have a high potential for emotion recognition based on EEG signals. Emotion is a mental state accompanied by physiological changes, as well as physical, behavioral, and mental This study . describes the relationship between EEG signals, brain wave patterns, and emotion analysis related to PTSD. PTSD is associated with the brain's response to memories, thoughts, and emotions related to trauma. EEG signals are a means of examining the electrical potential of human emotions. This research addresses issues of reliability and the concealment of genuine emotional behavior, proposing an automatic CNN-LSTM technique with the ResNet-152 algorithm, which achieves an accuracy of 98%. This study . proposes an innovative approach in the emotion recognition system, utilizing EEG calculations from various channels with a developed method of entropy known as Multivariate Multiscale Modified Distribution Entropy (MM-mDistE. This approach is combined with an Artificial Neural Network INTL. JOURNAL ON ICT VOL. NO. JUNE 2024 (ANN)-based model. The proposed system has been successfully tested using two different datasets, achieving higher accuracy rates compared to existing methods. In the GAMEEMO dataset, an average accuracy of 73% A 0. 67 for valence and 96. 78% A 0. 25 for arousal was attained. Additionally, for the DEAP dataset, the average accuracy percentage reached approximately 92. 57% A 1. 51 for valence and 80. 23% A 1. 83 for arousal. RESEARCH METHOD Proposed Methodology In the research methodology, the applied steps involve the use of a structured framework to guide each stage of the study. The research framework utilized, as depicted in Figure 1, consists of several phases. The initial step involves a literature review, which includes the evaluation of recent studies within the last 1 to 5 years. The subsequent phase is the data preparation stage, in which the EEG Emotion dataset containing more than 2,131 data samples is employed. Following this, the data preprocessing phase is conducted by converting data categories or labels into numerical representations. Emotion classification is performed using CNN and DNN, with parameter tuning to obtain the best model with the highest accuracy. The classification process comprises three stages: training, testing, and validation. Finally, an analysis of the experimental results is carried out, and conclusions are drawn based on the findings obtained from this research. Fig. Proposed Methodology Data Preparation This study involved training and testing an EEG Emotion dataset consisting of 2549 variables and 2131 rows of data. In this dataset, there are 2548 variables containing EEG signal data and one variable serving as the classification label. The data were collected from two participants, one male and one female, to determine neutral, positive, and negative emotional conditions. The data collection process was conducted using the Muse EEG headband equipped with dry electrodes, allowing for the recording of EEG activity at four location points: TP9. AF7. AF8, and TP10 . Further details about this dataset are elaborated in Table 1, with the following specifications. Subsequently, the dataset was divided into training and testing data, as presented in Table 2. Figure 2 shows an example of the EEG dataset variables used. DIAN PALUPI RINI ET AL. OPTIMIZING HYPERPARAMETERS OF CONVOLUTIONAL NEURAL NETWORK AND DEEP NEURAL NETWORK FOR EMOTION TABLE I DATASET SPECIFICATIONS Data label Number of data Positive Negative Neutral Total Fig. Dataset Variables In the data preparation process, the subsequent step involves the examination of missing values, which encompasses the identification of any absent data points within the dataset and assessing the degree to which these omissions impact the data quality. TABLE II DATA SPLITTING Validation Data First validation Train data 80% and test data 20% Second validation Train data 70% dan test data 30% Third validation Train data 60% dan test data 40% Data Preprocessing Label transformation is a crucial part of this research's data preprocessing. Many machine learning algorithms necessitate labels in numerical format, and label transformation is utilized to convert text or categorical class labels into numeric representations. The label transformation process from the dataset is depicted in Figure 3. In the illustration, there are three classes originally presented as text: "Neutral" is converted into class 0, "Positive" into class 1, and "Negative" into class 2. Label Encoder plays a crucial role in data analysis and machine learning. This tool allows for the conversion of class labels from text or categorical form into numerical representations, facilitating processing, analysis, and model training. Many machine learning algorithms require labels in numeric form, making Label Encoder instrumental in aligning data with the requirements of these algorithms. Moreover. Label Encoder also aids in data compatibility across different tools and analysis environments. With numeric labels, data can be easily integrated with various data analysis software and used for a wide range of statistical analyses. Additionally, it assists in handling multi-class classification problems, addressing class imbalance issues, and enables the creation of informative data visualizations. Thus. Label Encoder is a vital component in the workflow of data analysis and machine learning . INTL. JOURNAL ON ICT VOL. NO. JUNE 2024 Fig. Label Encoding Model Development The development of the model in this research consists of three stages: training, validation, and testing. In the training stage, the model is trained using the training dataset to generate an initial model. Subsequently, the validation stage is employed to evaluate the performance of the trained model using a separate validation This evaluation involves measuring various metrics, including accuracy, precision, recall, and F1-score, to ensure that the model can generalize well to unseen data. Once the model is deemed adequate in the validation stage, the final step is the testing stage, where the model is evaluated using an independent test dataset to measure its ultimate performance. The results from these stages will provide insights into the extent to which the developed model succeeds in the complex task of EEG emotion classification. Convolutional Neural Network Figure 4 illustrates the proposed architecture of the Convolutional Neural Network (CNN) used in this This CNN is designed specifically to process one-dimensional time series data with a length of The architecture comprises various types of layers, including Conv1D layers employed to extract important features from the data using 256 filters and the tanh activation function. Each Conv1D layer is followed by Batch Normalization for speeding up training and model optimization. Additionally. MaxPooling1D is used to reduce the data's dimensionality and produce a more compact representation. This convolution process is repeated with several Conv1D layers, each having a decreasing number of filters. After the convolution process is completed, the data is flattened into a one-dimensional vector and passed DIAN PALUPI RINI ET AL. OPTIMIZING HYPERPARAMETERS OF CONVOLUTIONAL NEURAL NETWORK AND DEEP NEURAL NETWORK FOR EMOTION through Dense layers with 'tanh' activation and dropout to prevent overfitting. This model has three neurons in the output layer with softmax activation used for generating class predictions. The proposed CNN architecture can be shown in figure 4. Input Layer Conv Layer 1 Neuron: 2548 Dataset EEG Filter: 256 Kernel: 10 Tanh Batch Normalization Maxpooling: 2 Conv Layer 2 Conv Layer 3 Conv Layer 4 Filter: 256 Kernel: 10 Tanh Batch Normalization Filter: 256 Kernel: 10 Tanh Batch Normalization Filter: 256 Kernel: 10 Tanh Batch Normalization Output Layer Dense Layer 2 Dense Layer 1 Neuron: 3 Softmax Neuron: 128 Tanh Dropout: 0. Neuron: 128 Tanh Dropout: 0. Flatten Maxpooling: 2 Fig. Proposed CNN architecture . Deep Neural Network In Figure 5, the architecture of the proposed Deep Neural Network (DNN) model in this study is depicted, designed for classification tasks using artificial neural networks. This DNN consists of multiple layers with various neurons and different activation functions. Each layer includes a Dense layer with fully connected layer. Batch Normalization for faster training, and Dropout to reduce overfitting. The ReLU activation function is employed within these layers. This model incorporates three output neurons used for classifying three emotion classes. In summary, this code snippet illustrates the architecture of the DNN model to be utilized for classifying EEG data into three emotion classes. Input Layer Hidden Layer 1 Hidden Layer 2 Hidden Layer 3 Neuron: 2548 Dataset EEG Neuron: 256 ReLU Batch Normalization Dropout: 0. Neuron: 256 ReLU Batch Normalization Dropout: 0. Neuron: 128 ReLU Batch Normalization Dropout: 0. Output Layer Hidden Layer 5 Hidden Layer 4 Neuron: 3 Softmax Neuron: 64 ReLU Batch Normalization Dropout: 0. Neuron: 128 ReLU Batch Normalization Dropout: 0. Fig. Proposed DNN architecture . Confusion Matrix Multilabel In this research, a multilabel confusion matrix is employed as the primary evaluation tool to assess the performance of the developed multilabel classification model. This confusion matrix allows researchers to identify and measure evaluation metrics such as precision, recall, and F1-score for each label class present in the data, as indicated in equations 1-4, because each sample in the dataset can have more than one possible INTL. JOURNAL ON ICT VOL. NO. JUNE 2024 Therefore, the multilabel confusion matrix provides a more comprehensive understanding of how well the model can handle complex multilabel classification problems. The results of this analysis will serve as a crucial guide in evaluating and improving the model to deliver more accurate and relevant outcomes within the context of this research, as illustrated in Label 0 in Table 3. Label 1 in Table 4, and Label 2 in Table 5. Tuning Parameter In this study, hyperparameter optimization for the performance of CNN and DNN is conducted to obtain the best model. The hyperparameter tuning process involves experimenting with various parameter combinations such as learning rate, the number of layers, the number of neurons, and others, with the aim of improving the accuracy and generalization of models in classifying EEG emotion data into three different classes . The results of this optimization will ensure that the CNN and DNN models used can effectively address classification challenges and provide optimal results. Additionally, with data splits of 80:20, 70:30, and 60:40, different models and accuracies are obtained, along with loss curves approaching 0, which serve as crucial indicators in evaluating model performance. Through careful exploration of hyperparameters and data split variations, this study aims to achieve optimal accuracy levels in classifying human emotions based on EEG TABLE i CONFUSION MATRIX LABEL 0 Actual Label 0 Prediction TPi FPi FPi FNi TNi FNi TNi TABLE IV CONFUSION MATRIX LABEL 1 Actual Label 1 Prediction TNi FNi FPi TPi FPi FNi TNi TABLE V CONFUSION MATRIX LABEL 2 Actual Label 2 Prediction TNi FPi FNi TNi FNi FPi TPi Here are the basic evaluation steps from the confusion matrix for each label. yaycaycaycycycaycayc = ycNycEycn ycNycAycn ycNycEycn yaycAycn ycNycAycn yaycEycn Ocycoycn=1 yco O 100% DIAN PALUPI RINI ET AL. OPTIMIZING HYPERPARAMETERS OF CONVOLUTIONAL NEURAL NETWORK AND DEEP NEURAL NETWORK FOR EMOTION ycEycyceycaycnycycnycuycu = Ocyco Ocycoycn=1 ycNycEycn ycn=1. aycEycn ycNycEycn ) ycIyceycaycaycoyco = Ocyco Ocycoycn=1 ycNycEycn ycn=1. cNycEycn yaycAycn ) ya1 ycycaycuycyce = O 100% . O 100% . 2OycEycyceycaycnycycnycuycuOycIyceycaycaycoyco ycEycyceycaycnycycnycuycu ycIyceycaycaycoyco IV. RESULTS AND DISCUSSION In this study, a comparison of the performance between CNN and DNN for EEG Emotion classification tasks was conducted by optimizing their hyperparameters. The results showed that CNN achieved the highest accuracy, especially when the data was divided in an 80:20 ratio. Furthermore. CNN also demonstrated outstanding performance by achieving precision, recall, and f1-score values close to 100 for label 1 in all data splitting schemes. However, the overall performance of both models did not differ significantly, with both showing good performance. Additional evidence of this can be seen from the loss curves approaching a value of 0 for both models. Accuracy curve CNN 80:20 . Accuracy curve CNN 70:30 . Accuracy curve CNN 60:40 . Accuracy curve DNN 80:20 . Accuracy curve DNN 70:30 . Accuracy curve DNN 60:40 Fig. The Accuracy Performance Curve of CNN and DNN INTL. JOURNAL ON ICT VOL. NO. JUNE 2024 The improvement in accuracy reflects the ability of CNN and DNN models to learn and adapt to patterns in the data gradually, as visually demonstrated in Figure 6. Although both models did not immediately reach the optimal level of accuracy at the beginning of the training, through continuous iterations, both models managed to produce increasingly accurate predictions for complex EEG Emotion data. This emphasizes that through continuous training and careful hyperparameter tuning, the performance of models in such classification tasks can be significantly enhanced. In this research, the loss curve is used as a crucial evaluation tool to measure the performance of CNN and DNN models during the training process, as can be seen in Figure 7. The loss curve helps to understand how well both models can minimize the difference between their predictions and the complex EEG Emotion data. By monitoring the loss curve, this study can identify the point where the models start to experience overfitting or underfitting, leading to better hyperparameter tuning. Loss curve CNN 80:20 . Loss curve DNN 80:20 . Loss curve CNN 70:30 . Loss curve DNN 70:30 . Loss curve CNN 60:40 . Loss curve DNN 60:40 Fig. The Loss Performance Curve of CNN and DNN Furthermore, the loss generated in this research is already approaching 0, which means that the CNN and DNN models have successfully reduced prediction errors significantly during the training process. Thus, the loss curve plays a role in ensuring that CNN and DNN models can effectively learn from the training data and make accurate predictions regarding human emotions. It is noteworthy that the loss curve of the DNN is smoother compared to the CNN, indicating a more gradual convergence of the DNN model during training. This suggests that the DNN model exhibits a steadier optimization process and experiences less fluctuation in prediction errors. DIAN PALUPI RINI ET AL. OPTIMIZING HYPERPARAMETERS OF CONVOLUTIONAL NEURAL NETWORK AND DEEP NEURAL NETWORK FOR EMOTION TABLE VI EVALUATION MODEL CNN TABLE VII EVALUATION MODEL DNN (SPLIT DATA 80:. Class Label Precision Recall F1Score Class Label Precision Recall F1Score TABLE Vi EVALUATION MODEL CNN (SPLIT DATA 70:. TABLE IX EVALUATION MODEL DNN (SPLIT DATA 70:. Class Label Precision Recall F1Score Class Label Precision Recall F1Score TABLE X SPLIT DATA EVALUATION MODEL CNN TABLE XI EVALUATION MODEL DNN (SPLIT DATA 70:. Class Label Precision Recall F1Score Class Label Precision Recall F1Score Additionally, the effectiveness of the model can also be gauged by examining the evaluation model described in Table 6 Ae Table 11. Both the CNN and DNN classification methods demonstrate commendable outcomes in precision, recall, and f1-score across all data split configurations, owing to the hyperparameter tuning proposed in this study. Moreover, detailed accuracy results for CNN and DNN, which attain noteworthy accuracy rates, are comprehensively presented in Table 12. This table offers a more holistic perspective on the performance of both models in the EEG Emotion classification task. TABLE XII THE ACCURACY RESULTS Accuracy Data CNN DNN 80:20 98,36% 98,13% 70:30 97,66% 97,66% 60:40 97,54% 97,19% INTL. JOURNAL ON ICT VOL. NO. JUNE 2024 CONCLUSION In this research, we conducted a performance comparison between Convolutional Neural Network (CNN) and Deep Neural Network (DNN) in the task of classifying EEG Emotion data. We optimized the hyperparameters of both models and tested various data splitting scenarios to evaluate their performance. The experimental results showed that CNN achieved the highest accuracy, especially when the data was split in an 80:20 ratio. However. DNN also demonstrated excellent performance, with no significant difference in These results were further reinforced by the loss curves, which approached the value of 0 in both models, indicating that both successfully reduced prediction errors significantly during training. The importance of selecting the right data splitting was also revealed, with an 80:20 split tending to yield better results. conclusion, both CNN and DNN have their respective advantages in the task of classifying EEG Emotion, and the choice of model depends on user preferences and the characteristics of the available data. Furthermore, the performance evaluation of both models was also assessed through the confusion matrix and precision, recall, and f1-score metrics. Both classification methods. CNN and DNN, exhibited satisfactory results in terms of performance evaluation for all optimized data splitting scenarios. DNN showed a smoother loss curve, indicating a more stable convergence during training. However. CNN remains a good choice, especially when high accuracy is a top priority. The results of this research provide valuable insights into the comparison between CNN and DNN in the EEG Emotion classification task, emphasizing the importance of hyperparameter tuning and proper data splitting in the context of analyzing complex data. DATA AND COMPUTER PROGRAM AVAILABILITY Data and program used in this paper can be accessed in https://w. com/datasets/birdy654/eeg-brainwave-dataset-feeling-emotions https://github. com/jordan-bird/eeg-feature-generation. ACKNOWLEDGMENT The research/publication of this article was funded by DIPA of pubtic Service Agency of Universitas Sriwijaya 2023. Nomor SP DIPA-023. 677515/2023. On November 30, 2022. In accordance with the Rector's Decree Number: 0188/UN9. l/SK/2023. On April l8, 2023 REFERENCES