%% 
%% Copyright 2007-2020 Elsevier Ltd
%% 
%% This file is part of the 'Elsarticle Bundle'.
%% ---------------------------------------------
%% 
%% It may be distributed under the conditions of the LaTeX Project Public
%% License, either version 1.2 of this license or (at your option) any
%% later version.  The latest version of this license is in
%%    http://www.latex-project.org/lppl.txt
%% and version 1.2 or later is part of all distributions of LaTeX
%% version 1999/12/01 or later.
%% 
%% The list of all files belonging to the 'Elsarticle Bundle' is
%% given in the file `manifest.txt'.
%% 
%% Template article for Elsevier's document class `elsarticle'
%% with harvard style bibliographic references

%\documentclass[preprint,12pt,authoryear]{elsarticle}

%% Use the option review to obtain double line spacing
%% \documentclass[authoryear,preprint,review,12pt]{elsarticle}

%% Use the options 1p,twocolumn; 3p; 3p,twocolumn; 5p; or 5p,twocolumn
%% for a journal layout:
%% \documentclass[final,1p,times,authoryear]{elsarticle}
%% \documentclass[final,1p,times,twocolumn,authoryear]{elsarticle}
%% \documentclass[final,3p,times,authoryear]{elsarticle}
%% \documentclass[final,3p,times,twocolumn,authoryear]{elsarticle}
%% \documentclass[final,5p,times,authoryear]{elsarticle}
 \documentclass[final,5p,times,twocolumn,authoryear]{elsarticle}

\usepackage{booktabs}

\usepackage{amsmath}
\usepackage{graphicx}
\usepackage{subfigure}
%% For including figures, graphicx.sty has been loaded in
%% elsarticle.cls. If you prefer to use the old commands
%% please give \usepackage{epsfig}

%% The amssymb package provides various useful mathematical symbols

\usepackage{amssymb}
\usepackage{lipsum}
\usepackage{tikz}
\usetikzlibrary{shapes.geometric, arrows}
%\documentclass[10pt]{article}
\usepackage{times}
%% The amsthm package provides extended theorem environments
%% \usepackage{amsthm}
%% The lineno packages adds line numbers. Start line numbering with
%% \begin{linenumbers}, end it with \end{linenumbers}. Or switch it on
%% for the whole article with \linenumbers.
%% \usepackage{lineno}

%% You might want to define your own abbreviated commands for common used terms, e.g.:
\newcommand{\kms}{km\,s$^{-1}$}
\newcommand{\msun}{$M_\odot}
\makeatletter
\def\ps@pprintTitle{%
  \let\@oddhead\@empty
  \let\@evenhead\@empty
  \def\@oddfoot{\reset@font\hfil\thepage\hfil}
  \let\@evenfoot\@oddfoot
}
\makeatother
\journal{Results in Physics}

\begin{document}

\setcitestyle{numbers}
\setcitestyle{square}
\begin{frontmatter}

%% Title, authors and addresses

%% use the tnoteref command within \title for footnotes;
%% use the tnotetext command for theassociated footnote;
%% use the fnref command within \author or \affiliation for footnotes;
%% use the fntext command for theassociated footnote;
%% use the corref command within \author for corresponding author footnotes;
%% use the cortext command for theassociated footnote;
%% use the ead command for the email address,
%% and the form \ead[url] for the home page:
%% \title{Title\tnoteref{label1}}
%% \tnotetext[label1]{}
%% \author{Name\corref{cor1}\fnref{label2}}
%% \ead{email address}
%% \ead[url]{home page}
%% \fntext[label2]{}
%% \cortext[cor1]{}
%% \affiliation{organization={},
%%            addressline={}, 
%%            city={},
%%            postcode={}, 
%%            state={},
%%            country={}}
%% \fntext[label3]{}

%\title{
%Real-Time EEG-Based Emotion Recognition Using PSO-Optimized Support Vector Machines for Enhanced Classification of Arousal and Valence}

\title{Optimized Emotion Recognition Using Swarm Intelligence and Explainable AI for EEG Based Analysis
}
\author[label1]{Niharika Gudikandula}\corref{cor1}
\cortext[cor1]{Corresponding author}
\ead{gniharikashiloh@gmail.com} 
\author[label2]{Ravichander Janapati}
 \author[label2]{Sridhar Chintala}





\affiliation[label1]{organization={SR University},
Department={School of Engineering},
            addressline={Ananthasagar, Hasanparthy}, 
            city={Warngal},
            postcode={ 506371}, 
            state={Telangana},
            country={India},
            Corresponding author={gniharikashiloh@gmail.com}}


\affiliation[label2]{organization={SR University},Department ={School of
Computer Science \& Artificial Intelligence},
            addressline={Ananthasagar, Hasanparthy}, 
            city={Warangal},
            postcode={506371}, 
            state={Telangana},
            country={India}}



 

%% use optional labels to link authors explicitly to addresses:
%% \author[label1,label2]{}
%% \affiliation[label1]{organization={},
%%             addressline={},
%%             city={},
%%             postcode={},
%%             state={},
%%             country={}}
%%
%% \affiliation[label2]{organization={},
%%             addressline={},
%%             city={},
%%             postcode={},
%%             state={},
%%             country={}}

\begin{abstract}
%% Text of abstract
Identifying the emotional arousal and valence states of people is a key concern in many fields, including adapting social life for those with different abilities. Automated systems for this purpose cannot rely only on basic postures and facial expressions. More effective methods, such as neural signal analysis, can enhance traditional techniques by using EEG data to understand emotional states and cognitive processes. In our current work, we utilised the GAMEEMO dataset, which allows for the integration of various game environment variables with matching psychological state labels. This study focuses on two emotions: positive and negative. Collecting EEG signals from the brain involves pre-processing techniques like bandpass filtering and wavelet transforms, which are sensitive to changes in temporal frequency. Next, we extracted features using the Fast Fourier Transform to create vectors. Finally, application of the extracted time-frequency features to a machine learning method called Support Vector Machines was carried out. This involved a particle swarm optimization classifier for emotion classification. Our study examines multiple emotions, specifically "Arousal" and "Valence," to accurately classify LANV, LAPV, HANV, and HAPV. The results demonstrate the effectiveness of the proposed SVM with PSO, achieving a 99.37\% accuracy in emotion detection. Additionally, explainable artificial intelligence methods like SHAP and LIME were employed to identify the most important features that can further improve the accuracy of EEG-based emotion classifiers.
\end{abstract}

%%Graphical abstract
%\begin{graphicalabstract}
%\includegraphics{grabs}
%\end{graphicalabstract}

%%Research highlights
%\begin{highlights}
%\item Research highlight 1
%\item Research highlight 2
%\end{highlights}

\begin{keyword}

Electroencephalography \sep GAMEEMO dataset \sep Particle Swarm Optimization \sep Support Vector Machine  \sep Explainable artificial intelligence  


\end{keyword}




%\tableofcontents

%% \linenumbers

%% main text


\begin{abstract}
The identification of the emotional arousal and valence states of the people has been a major concern in various disciplines, including the adaptation of social life to differently able people. Automated identification systems for such purposes can not rely solely on basic postures and facial gestures alone. Advanced methodologies, such as neural signal analysis, can complement conventional methodologies by using EEG data with a view to understanding emotional states and cognitive processes. In order to develop a robust system, in the current work, we utilized the GAMEEMO dataset, which has the advantage of combining the flexibility of incorporating various game environment variables and coupling them with corresponding psychological state labels. For the purpose of this study, two emotions are considered for the classification: Positive and Negative emotions. Acquiring EEG signals from the brain underwent some pre-processing techniques such as bandpass filter and wavelet transform is sensitive to temporal frequency variations. Subsequently, feature extraction is performed using the Fast Fourier Transform from which vectors were extracted. Finally, the extracted time-frequency features were applied to a machine learning technique called Support Vector Machines, having a particle swam optimization classifier for emotion classification. Our study considers multiple emotions, specifically 'Arousal' and 'Valence' for the precision of classification of LANV, LAPV, HANV and HAPV. These experimental results represent the complete work, proving the significance and efficiency of the proposed SVM with the PSO achieved 99.37\% of the accuracy of emotion detection. In addition, our study used explainable artificial intelligence methods like SHAP and LIME to determine which features are the most important to improve the accuracy of EEG-based emotion classifiers.

% Please include a maximum of seven keywords

\end{abstract}
\end{frontmatter}

%\tableofcontents

%% \linenumbers

%% main text

\section{Introduction}

Emotions are fundamental to the change in behavior and performance that signifies learning, reflecting a sophisticated level of intelligence \cite{mayer1996emotional}. These are considered based on the implicit or cognitive sense, the neurological and physiological mechanisms that underlie it, the visible behavioral patterns, and the observable expressive patterns, especially those manifested in facial expressions \cite{izard2013human}. Theories Plutchik, Ekman, and James-Lange classify emotions.\cite{plutchik2001integration}, \cite{lang1994varieties}. Plutchik's theory divides emotions into basic (for example, joy, fear, anger) and secondary (for example, aggression, submission) categories shown in Figure \ref{emodel}. Ekman's discrete model identifies The six primary feelings are sorrow, joy, annoyance, distaste, anxiety, and amazement. James-Lange theory categorizes emotions using a dual-dimensional arousal valence paradigm, in which valence varies from negative (unpleasant) to optimistic (pleasurable), and arousal runs from minimal (passive) to excessive (active) \cite{abdulrahman2021comprehensive}. Emotions are accurately interpreted through physiological signals from electroencephalography (EEG)\cite{liu2024eeg}. EEG data provide high temporal resolution and meaningful information accessible using inexpensive and portable EEG equipment. Artifact removal methods are used to extract clean EEG signals for feature extraction stages \cite{mumtaz2021review}. An EEG-based system enables the interpretation of specific elements of the individual's mental state. These emotions can be captured during synaptic neuronal dendrite excitations. Brain-Computer Interaction (BCI) \cite{dhiman2023machine} technology places electrodes on top of the head to assess the response of the neuronal system to current flow \cite{fares2022realm}. The wearable EEG with emotion identification might lead to breakthroughs in electronic learning, playing games, medical care, human-computer interface, and automobiles.
\begin{figure}
    \centering
    \includegraphics[width=80mm,height=60mm]{img1.png}
    \caption{Emotion Model}
    \label{emodel}
\end{figure}

\begin{figure*}[!ht]
    \centering
    \includegraphics[width=0.6\textwidth, height=0.30\textheight]{svmpsoblk34.png} % Adjust 'width' and 'height' as needed
    \caption{Workflow of Electroencephalogram-based model for emotion recognition using the GAMEEMO database}
    \label{wflow}
\end{figure*} Technological advances have expanded the scope of brain–computer interfaces (BCIs) to include artificial intelligence for emotion recognition, facial expression, and eye movement analysis, as well as detection of limb and hand movements. The last generation of self-decision making through advanced algorithms such as machine learning (ML) has inspired researchers to use ML in BCI systems to enhance and perform effective tasks. ML is a branch of statistics and computer science that utilizes computers to perform tasks without explicit programming \cite{wani2022machine} ,\cite{rasheed2021review}. Explainable AI(XAI) enables people to understand and have confidence in the outcomes produced by machine learning algorithms achieved by using the techniques VarImp, SHAP, and LIME produce visualizations. The rise in the usage of electronic devices has led to an increase in time spent on social media, online gaming, and other digital activities. Passive activities such as watching films and playing computer games provide a more immersive and interactive experience, where people engage directly with the environment and adopt the roles of game characters \cite{isbister2015guidelines}. Understanding emotions during game play can offer insight into psychological well-being and enhance game design for better user experiences. This active participation significantly impacts emotions, making it crucial to study emotion recognition in gaming contexts.  




Previous research has brought several improvements in EEG emotion recognition by presenting different algorithms based on different features of EEG signals. Using various ML techniques and show novel research avenues and possible drawbacks.\cite{aung2022entropy} presents an Entropy-enhanced ANN framework based on Multichannel EEG Using the newly proposed MM-mDistEn, achieving 95. 73\% in valence and 96.78\% in arousal on the Game Emotion Database (GAMEEMO) dataset and 92.57\% in valence and 80.23\% in arousal on the Emotion Awareness dataset. The author has proposed the application of Tunable Q-factor wavelet transforms for feature extraction, which transforms EEG subbands into TQWT feature block sequences. The hybrid convolutional repeat neural network with CNN-LSTM fusion has achieved a performance of 95 33\% \cite{zhong2023eeg}. \cite{yu2022eeg} study uses the VR emotional EEG dataset, employing 3D virtual reality videos as mood-induction procedures. It achieved an accuracy of 73.77\% using gamma, beta, alpha, and theta in terms of their relative powers. Spearman analysis revealed that the frontal and occipital regions play a critical role in emotion processing.
As in \cite{aslan2022cnn}, this work presents a GoogLeNet-based deep learning approach where EEG signals are transformed into scalograms using the continuous wavelet transform and, in general, different convolutional architectures achieve accuracies of up to 98. 78\% for the classification of the GAMEEMO database using SVM, k-NN and ELM classifiers. Likewise, the accuracy over 99\% in DEAP, DREAMER and GAMEEMO was recorded by PrimePatNet87, a hand-crafted TQWT network\cite{dogan2021primepatnet87}. More work has been conducted on the implementation of techniques such as bidirectional LSTM and capsule networks to increase the precision of emote categorization in different datasets, including GAMEEMO and SEED\cite{alakus2020emotion}\cite{toraman2021gameemo}. 

The key contributions of the study we conducted are described below: 

• Analyzes the constraints highlighted in previous research and generates superior results in each aspect.


• The pso svm model utilizes the optimization technology for emotion recognition
with EEG signals, which were initially used for emotion recognition, showing the wide
application and an efficient AI to improve the relationship between features;


• The original EEG signal is transformed into a 1D data set consisting
of temporal, spatial, and frequency information. The proposed svm derives spatial
and FFT,PSD frequency features, as WT derives temporal features. This complete
feature extraction method leads to more precise emotion recognition results;


• Performance metrics of the PSO SVM model showed the best results when evaluated against the GAMEEMO dataset.
To manage signal-to-noise ratios, the signal display achieved high recognition accuracy.
The performance results from the use of this model showed better accuracy than those of other techniques tested. 
Thus, the target estimation for the emotion extracted from the features of the EEG signal is performed using a Particle Swarm Optimization (PSO) framework. This optimization minimizes two criteria: to enhance the generalization of the SVM-based regression model. The first criterion is the empirical risk, measured by mean square error (MSE), reflecting the precision of the prediction. The second is the number of support vectors (SV), indicating the sparsity of the model.


\subsubsection{Organization of the Manuscript}
The following is the outline of the article. 
 Sections I and II offer background information on the theme of emotion classification and outline the proposed analysis. Section III details the experimental data set used, along with the preprocessing steps and time-domain feature extraction methods used. In Section IV, the performance of the SVM-PSO approach is presented through experimental results, highlighting its effectiveness in addressing EEG-based classification challenges, and comparing it with other existing methods. Finally, Section V concludes the paper. 






\begin{table}[!ht]
\centering 
\scriptsize
\caption{Accuracy Comparison With Existing Emotion Recognition Methods Using GAMEEMO Dataset}
\begin{tabular}{p{0.6cm} p{3cm} p{1.5cm} p{1.5cm}}
\toprule
\textbf{Article} & \textbf{Methods used} & \textbf{Emotions} & \textbf{Accuracy} \\ [5pt]
\midrule
\cite{aung2022entropy} & ANN model with multivariate multiscale modified-distribution entropy
 &  Valence and Arousal & 95.73\% and 96.78\% \\ [5pt]
\cite{aslan2022cnn} & GoogLeNet-based deep learning method using EEG signals, through Continuous Wavelet Transform & Positive and Negative emotions & 98.78\%  with SVM, 98.53\% with k-NN, and 98.41\% with ELM  98.78\% \\ [5pt]
\cite{dogan2021primepatnet87} & PrimePatNet87, a hand-crafted network using prime pattern and TQWT techniques 
 & Arousal, Valence & 99\%  \\ [5pt]
\cite{alakus2020emotion} & Spectral entropy, classifying with bidirectional LSTM &  Valence and Arousal  & 76.91\%  \\ [5pt]
\cite{su2023subject} & Projection dictionary learning with the fast PDPL technique using a genetic algorithm &  Positive, Neutral, and Negative & 69.89\%  \\ [5pt]
\cite{toraman2021gameemo} & General non-subject-based model and applies Capsule Networks for binary and multi-class recognition & Positive and Negative emotions & 98.38\%  \\ [5pt]
\cite{tuncer2022ledpatnet19} & LEDPat-Net19, an advanced emotion recognition model with TQWT multilevel feature generation network & Arousal, Dominance and Valance   & 99.29\% \\ [5pt]
Proposed Method & Bandpass filtering using wavelet transform with swarm optimization using SVM & Arousal and Valance & 99.37\% with PSO based SVM, KNN-71.39\% and CNN-62.31\%  \\ [5pt]
\bottomrule
\end{tabular}
\label{t1}
\end{table}


\section{Proposed Methodology
}
The EEG-based model for emotion recognition discussed in this
paper is shown in Figure 1. Initially, the raw EEG signal is subjected to pre-processing from the raw data. Thus, the following features are chosen from the EEG data:
Finally, the extracted eeg features are categorized by the
classifier. The following step-by-step description outlines the model.  The general process of the emotion recognition system on the physiological data is depicted as a block diagram \ref{wflow}.


\subsection{Preprocessing} 
 Preprocessing of EEG signals achieved through the bandpass filtering, wavelet transform and Fourier transform methods \cite{abenna2022eeg}, \cite{bajaj2020wavelets}. These techniques improve the signal-to-noise ratio (SNR), reduce computational cost, and improve the accuracy of emotions. Balancing noise reduction with the preservation of signal integrity requires careful control over the filter intensity and the level of detail retained. 

To develop a multiclass classification model on the GAMEEEMO dataset, we analyze the signals of the EEG data representing the positive emotions in the zones of LAPV and HAPV and those representing the negative emotions in the zones of LANV and HANV separately. Afterward, signals of the same emotion type are averaged to develop an overall single representative EEG signal of each emotion class. Hence, in this process, the recording of EEG signals passes through a bandpass filter to isolate the desired frequency bands where the cutoff value is 0.05 Hz at lower and 45 Hz at high and the wavelet is denoised using wavelet 'db4' with L=11 by decomposition \cite{atangana2020suitable}.
 The filtering process is measurable as

\begin{equation}
  y(t) = \sum_{n=0}^{N-1} h[n] \cdot x(t - n)  
\end{equation}


y(t)= filtered signal.
 x(t)= raw signal.
 h [n] = impulse response of the bandpass filter.
 N is the filter order. 
\begin{figure}
    \centering
    \includegraphics[width=80mm,height=60mm]{borsgl.png}
    \caption{The raw and pre-processed signals for the Boring emotion}
    \label{P1}
\end{figure}
\begin{figure*}[ht]
\centering
\begin{minipage}{0.50\linewidth}
    \centering
    \begin{subfigure}{\linewidth}
        \includegraphics[width=\linewidth]{fe1b+.png}
        \caption{The Time frequency domain features of Boring emotion}
        \label{1}
    \end{subfigure}
    \vspace{0} % Reduced vertical space between rows of subfigures
    \begin{subfigure}{\linewidth}
    \includegraphics[width=\linewidth]{fe1c+.png}
        \caption{The Time frequency domain features of Calm emotion}
        \label{2}
    \end{subfigure}
  \label{fig:figures1}
\end{minipage}
\hspace{0.1cm} % Reduced horizontal space between mini pages
\begin{minipage}{0.48\linewidth}
    \centering
    \begin{subfigure}{\linewidth}
    \includegraphics[width=\linewidth]{feh+.png}
        \caption{The Time frequency domain features of Horror emotion}
        \label{3}
    \end{subfigure}
    \vspace{0} % Reduced vertical space between rows of subfigures
    
    \begin{subfigure}{\linewidth}
    \includegraphics[width=\linewidth]{fe1f+.png}
        \caption{The Time frequency domain features of Funny emotion}
        \label{4}
    \end{subfigure}
    \label{fig:figures2}
\end{minipage}
\end{figure*}Wavelet de-noising removes artifacts from the EEG readings. Figure \ref{P1} displays the raw, clean and filtered signals for boring emotions. The graphs for the remaining emotions, calm, horror, and funny, show similar patterns. The denoising process typically involves threshold, the wavelet coefficients can be illustrated as: 
 
\begin{equation}
\hat{c}_j = \left\{
\begin{array}{ll}
c_j & \text{if } |c_j| > \lambda \\
0 & \text{if } |c_j| \leq \lambda
\end{array}
\right.
\end{equation}


$c_j$ are the wavelet coefficients, $\lambda$ is the threshold level,

\( \hat{c}_j \) are the denoised wavelet coefficients.
\\


\begin{table}[h!]
\centering
\scriptsize
\caption{ Optimization Iterations and Function Evaluations}
\begin{tabular}{c c c c c}
\hline
Iteration & f-count & \multicolumn{2}{c}{Best} & Stall \\
          &         & f(x) & Mean f(x) & Iterations \\
\hline
0  &  50   & 0.02721 & 0.1216  & 0  \\
1  &  100  & 0.02471 & 0.3624  & 0  \\
2  &  150  & 0.02283 & 0.106   & 0  \\
3  &  200  & 0.02127 & 0.09142 & 0  \\
4  &  250  & 0.01783 & 0.09686 & 1  \\
5  &  300  & 0.01783 & 0.06921 & 1  \\
6  &  350  & 0.01783 & 0.05688 & 2  \\
7  &  400  & 0.01783 & 0.06898 & 3  \\
8  &  450  & 0.01783 & 0.04266 & 4  \\
9  &  500  & 0.01783 & 0.06975 & 5  \\
10 &  550  & 0.01783 & 0.04315 & 6  \\
11 &  600  & 0.01783 & 0.0291  & 7  \\
12 &  650  & 0.01783 & 0.03437 & 8  \\
13 &  700  & 0.01658 & 0.02783 & 1  \\
14 &  750  & 0.01658 & 0.02879 & 1  \\
15 &  800  & 0.01658 & 0.04934 & 2  \\
16 &  850  & 0.01658 & 0.04337 & 3  \\
17 &  900  & 0.01658 & 0.02934 & 4  \\
18 &  950  & 0.01658 & 0.03055 & 5  \\
19 &  1000 & 0.01658 & 0.0299  & 6  \\
20 &  1050 & 0.01658 & 0.03025 & 7  \\
21 &  1100 & 0.01658 & 0.03205 & 8  \\
22 &  1150 & 0.01658 & 0.02958 & 9  \\
23 &  1200 & 0.01658 & 0.02917 & 10 \\
24 &  1250 & 0.01658 & 0.04261 & 11 \\
25 &  1300 & 0.01658 & 0.04261 & 12 \\
26 &  1350 & 0.01658 & 0.04913 & 13 \\
27 &  1400 & 0.01658 & 0.04333 & 14 \\
28 &  1450 & 0.01658 & 0.04997 & 15 \\
29 &  1500 & 0.01658 & 0.02953 & 16 \\
30 &  1550 & 0.01658 & 0.03032 & 17 \\
31 &  1600 & 0.01658 & 0.03047 & 18 \\
32 &  1650 & 0.01658 & 0.02941 & 19 \\
\hline
\end{tabular}

\label{MA}
\end{table}

The raw EEG signal underwent segmentation that defined an EEG epoch creates 4-second intervals for each channel, with the subsequent epoch obtained by shifting the window by 1 second. After segmentation, the features were computed independently for each epoch and channel, focusing on the commonly used features. Three types of features were extracted from EEG data: time domain features (TDFs), frequency domain features (FDFs) from power spectral density (PSD), and time frequency domain features (TFDFs)
from discrete wavelet transform (DWT) coefficients\cite{boonyakitanont2020review}.  Epochs are created by dividing the EEG signal into fixed-length segments. Each segment (epoch) can be represented as:

\begin{equation}
\text{Epoch}_k = \{x_{t_0}, x_{t_1}, \dots, x_{t_n}\}
\end{equation}
\( k \) denotes the epoch number.\\
 \( t_0, t_1, \dots, t_n \) are the time indices within the segment.
\\

\subsection{Feature Extraction}

EEG signals are inherently complex and rich in information. We are focusing on channel selection spatial averaging of features from the left and right hemispheres. In feature extraction, the intention is to achieve a reduction in the dimensions of the EEG data while maintaining emotion-related information. FE was performed on the cleaned EEG signals by segmenting them into epochs of 16 seconds each. The features in both the time and frequency domains were recovered \cite{wang2021review}, \cite{pawar2020feature}. 
The time domain feature in our work adopted the mean of Table \ref{MA}, variance, skew, and kurtosis and power spectral density (PSD), fast Fourier transform (FFT) of the frequency domain features were applied. Figures \ref{1}, \ref{2}, \ref{3}, and \ref{4} present the characteristics of the FFT, PSD, and time domains, providing a comprehensive overview of the characteristics extracted for analysis.
These features capture the essential characteristics of EEG signals for subsequent classification.


The Fast Fourier Transform (FFT) is used to extract frequency-domain features:

\begin{equation}
 X(k) = \sum_{n=0}^{N-1} x(n) \cdot e^{-j \frac{2\pi fn}{N}}
\end{equation}


 \( X(f) \)  signifies the frequency characteristics of the signal.
\( x[n] \): signal representation of the time domain.
\( N \): number of points in the EEG signal.


Welch PSD estimation method:

\begin{equation}
 P_{xx}(f) = \frac{1}{K} \sum_{k=1}^{K} \left| X_k(f) \right|^2
\end{equation}


 \( P_{xx}(f) \): power spectral density.
\( X_k(f) \): Fourier transform of the \( k \) length of segments.


Time-Domain Features


\begin{equation}
 \mu = \frac{1}{N} \sum_{i=1}^{N} x_i
\end{equation}


 \begin{equation}
 \sigma^2 = \frac{1}{N-1} \sum_{i=1}^{N} (x_i - \mu)^2
\end{equation}


\begin{equation}
 \gamma_1 = \frac{1}{N} \sum_{i=1}^{N} \frac{(x_i - \mu)^3}{\sigma^3}
\end{equation}


\begin{equation}
 \gamma_2 = \frac{1}{N} \sum_{i=1}^{N} \frac{(x_i - \mu)^4}{\sigma^4} - 3
\end{equation}


With respect to segmentation, Data augmentation(DA) refers to the process of creating new samples to supplement an existing data set by modifying the existing samples. The gains after normalization for more invariant features increase the classification performance and its stability, especially within an environment based on EEG records. The purpose of DA is to minimize sensitivity from transformations in terms of making a classifier less biased and more invariant to such transformations and to enhance the model for performing better even on unseen data. Data enhancement strategies, such as the addition of Gaussian noise to the EEG signals, time-shifting, and amplitude scaling, were employed in order to see temporal and amplitude changes. The augmentation resulted in a four-fold increase in the size of the data set. 

Adding Gaussian noise to the signal:
\begin{equation}
    x_{\text{aug}}(t) = x(t) + \mathcal{N}(0, \sigma^2)
\end{equation}
\begin{equation}
 x_{\text{aug}}(t) = x(t + \Delta t) 
\end{equation}
\( \Delta t \): shift amount.
 \( \mathcal{N}(0, \sigma^2) \): Variance and mean zero of white noise \( \sigma^2 \).


\begin{figure}[h]
    \centering
    \includegraphics[width=90mm,height=70mm]{xai44+.png}
    \caption{Classification error C and the kernel scale $\sigma$}
    \label{CROS}
\end{figure}

\begin{figure}
  \centering
\includegraphics[width=60mm,height=85mm]{svmpsoflw.png}
    \caption{Flowchart for SVM PSO optimization  algorithm.}
    \label{f2}
\end{figure}
\subsection{Explainable Artificial Intelligence for Emotion Analysis}
 XAI provide users with understandable explanations of AI systems. This is especially important for establishing trust and identifying latent bias in areas such as clinical diagnosis and credit risk assessments. Explainability provides end-users with an interpretation of AI predictions to increase system accuracy, equity, and adherence to ethical standards, in addition to improving the performance of AI models\cite{saeed2023explainable}.
Objective measurements in XAI are more appropriate for assessment than subjective metrics associated with human-centric factors.  Such metrics generally emphasize explainer, such as local interpretable model-agnostic explanations (LIME) and Shapley additive explanations (SHAP).
 \cite{sisk2023analyzing} Alternative explanation approaches encompass a counterfactual approach, in which explanations are assessed with greater logical rigor.  The primary element of objective metrics encompasses instruments that utilize a diverse array of XAI models and techniques, subsequently analyzing the results in an innovative manner. EEG data are inherently complex and nonlinear; therefore, it is difficult to understand how models extract features and classify emotions. XAI techniques that enable the identification of the most relevant Mean characteristics, channels that contribute to specific emotional states identified by SHAP and LIME.
 

 SHAP values were computed using a perturbation-based approximation. Since the SVM model used in this study does not support native SHAP explainers such as TreeExplainer or KernelSHAP, a model-agnostic method was implemented. For each feature $f_i$, a perturbed version of the test set $X_{\text{perturbed}}$ was generated by replacing the feature $i^{\text{th}}$ with random noise drawn from a uniform distribution that matches the original feature range. Predictions were made for the original inputs $X_{\text{test}}$ and perturbed, and the SHAP value was calculated as:

\begin{equation}
\text{SHAP}_{i,j} = \hat{y}_{\text{original},j} - \hat{y}_{\text{perturbed},j}  
\end{equation}

where $\hat{y}_{\text{original},j}$ and $\hat{y}_{\text{perturbed},j}$ represent the predictions for the instance $j^{\text{th}}$ with and without the influence of feature $f_i$, respectively. This marginal contribution quantifies the importance of individual features in model decisions.

Although this approach does not consider all permutations of feature subsets (as in exact Shapley computations), it provides a computationally feasible way to approximate SHAP values for high-dimensional EEG datasets.





\subsection{PSO based SVM Classification}

In the third stage, an emotion categorization of the features extracted in the proposed method is performed. The most effective techniques of machine learning are tested to get the best results. We evaluated three popular classification methods, including,  Fully Informed PSO(FIPSO), Multi-Objective PSO (MOPSO) and Particle Swarm Optimized (PSO) Support Vector Machines (SVM).

\begin{table}[htbp]
\centering
\scriptsize
\caption{Proposed work Configuration and Data Split Summary}
\begin{tabular}{p{2.5cm} p{4cm}}
\hline
\textbf{Component} & \textbf{Setting / Description} \\
\hline
Train/Test Split & 80\% training, 20\% testing using \texttt{cvpartition('HoldOut', 0.2)} \\

Cross-Validation & 5-fold cross-validation applied during PSO on training data \\

Classifier & Support Vector Machine (SVM) with RBF kernel, implemented using \texttt{fitcecoc} \\

Hyperparameter 1 ($C$) & Range: $[10^{-3}, 10^{3}]$ -- box constraint for SVM \\

Hyperparameter 2 ($\sigma$) & Range: $[10^{-3}, 10^{3}]$ -- kernel scale for RBF function \\

Swarm Size & 50 particles \\

Maximum Iterations & 100 iterations \\

Objective Function & Classification error from 5-fold CV using \texttt{kfoldLoss} \\

Optimization Algorithm & \texttt{particleswarm} function in MATLAB \\
\hline
\end{tabular}
\label{tab:psosvm-settings}
\end{table}

 The SVM is capable of being quite a strong classifier in the investigation of hyperplanes, the margin between the emotion classes of different natures it maximizes to facilitate generalization \cite{abdullah2021machine}. Inspired by the way birds interact with each other, PSO is an optimization method. It offers a fully automated and efficient method for tuning these parameters for better accuracy and reliability in classification tasks, especially when complex datasets, such as EEG signals, are concerned.
 The SVM used a kernel of radial basis function (RBF), which required tuning two essential hyperparameters: the box constraint parameter $C$ and the kernel scale $\sigma$. The hyperparameter search space was set as $C \in [10^{-3}, 10^{3}]$ and $\sigma \in [10^{-3}, 10^{3}]$ to ensure a comprehensive search for optimal generalization. PSO was configured with a swarm size of 50 particles and a maximum of 100 iterations. The objective function minimized during optimization was the classification error obtained through 5-fold cross-validation, using MATLAB’s fitcecoc for multiclass SVM training. Prior to optimization, the entire dataset was split using an 80/20 training-test split through MATLAB's cvpartition function with the 'HoldOut' method. PSO optimization was conducted only on the training data to prevent information leakage. Once the optimal values $C$ and $\sigma$ were determined, a final SVM model was trained on the full training data and evaluated on the 20\% held test set. This setup ensures both robust parameter tuning through internal cross-validation and reliable generalization performance on unseen data.
\begin{table}
\centering
\scriptsize
\caption{Pseudo-Code of PSO based SVM Algorithm}
\begin{tabular}{p{7cm}}
\toprule
\textit{ Pseudo-Code of SVM-PSO Algorithm} \\ 
\midrule
\textit{1. Initialize the swarm of particles $S$  and corresponding velocity vectors.} \\ 
\textit{2. For each iteration $t = 1$ to max\_iterations do:} \\ 
\textit{3. For each particle $i = 1$ to $S$ (total particles) do:} \\ 
\textit{4. Evaluate the fitness of each particle based on SVM classification accuracy on a validation set.} \\ 
\textit{5. For each dimension $d = 1$ to the number of parameters (2 for $C$ and $\gamma$) do:} \\ 
\textit{6. Update the velocity of each particle $i$ using:} \\ 
\textit{\hspace{1cm}  The particle’s own best position (pbest).} \\ 
\textit{\hspace{1cm}  The global best position (gbest) in the swarm.} \\ 
\textit{7. Update the position of particle $i$ using the updated velocity.} \\ 
\textit{8. End For (dimension update loop)} \\ 
\textit{9. If the fitness of particle $i$ is better than its pbest, update pbest.} \\ 
\textit{10. End For (particle loop)} \\ 
\textit{11. If any particle's fitness is better than the global best (gbest), update gbest.} \\ 
\textit{12. End For (iteration loop)} \\ 
\textit{13. Train the final SVM model using the best hyperparameter $C$ and $\gamma$ obtained from gbest.} \\ 
\textit{14. Terminate the process if the stopping criterion is met .} \\ 
\bottomrule
\end{tabular}

\label{sudo}
\end{table}


In this work, PSO was used to fine-tune the SVM parameters \cite{huang2008distributed}, including the regularization parameter \(C\) and the kernel scale \(\sigma\). The objective function minimized by PSO is the classification error through a five-fold cross-validation, as shown in Figure \ref{CROS}. The optimized classifier was trained on the augmented data set and tested on a separate test set. The performance of the model was determined on the accuracy, precision, recall, and F1 score to comprehensively judge performance for a wide variety of classification scenarios.
The following is the pseudocode for the SVM-PSO algorithm in Table \ref{sudo}. The PSO obtains a population of solutions in view of the behavior of a swarm of particles \cite{shami2022particle}. Particles adapt their positions in the search space according to their best-found positions and the global best among all particles.  PSO finds the optimal values for the hyperparameters \( C \) and \( \gamma \) that minimize the classification error.
Mathematically, the velocity of a particle, \( i \), is revised using the following equation at time \( n + 1 \).


 

\begin{equation}
v_{i}^{n+1} + x_{i}^{n+1} = v_{i}^n + x_{i}^n + c_1 r_1 (p_{i}^n - x_{i}^n) + c_2 r_2 (p_{gd}^n - x_{i}^n)
\end{equation}

The velocity of the particles \(v_i\) guides position updates based on the best positions of the individual (\(pbest_i\)) and global (\(gbest\)). \(c_1\) (cognitive) and \(c_2\) the social acceleration constant, scaled by uniform random factors \(r_1\), \(r_2\) respectively between 0 and 1, while \(w\)is a weighing factor to balance exploration and exploitation. 
Positions of the particle \( i \) are updated using:
\begin{equation}
x_{i}^{(n+1)} = x_{i}^{(n)} + v_{i}^{(n+1)} 
\end{equation}
 
It allows the particles to perform an iterative process to explore the search space and converge towards the global optimum solution. These can be effectively illustrated using the flow chart shown in Figure \ref{f2}.

Furthermore, we implemented Multi-Objective PSO (MOPSO) SVM and Fully Informed PSO (FIPSO) SVM classifiers to examine emotions derived from EEG data. FIPSO \cite{ren2024surrogate} optimization algorithm to fine-tune the hyperparameter of an SVM classifier. Specifically, it optimizes two crucial parameters of the RBF kernel SVM, the Box Constraint (C) and the Kernel Scale ( $\sigma$). The FIPSO algorithm mimics the social behavior of swarming particles, but with an added inertia weight adjustment mechanism, which helps balance exploration and exploitation more effectively than standard PSO.
The objective function used during FIPSO is based on the mean squared error (MSE) calculated on the training dataset. FIPSO searches the hyperparameter space within defined bounds over a 100 of iterations and swarm size to minimize this MSE. Once the optimal values for C and $\sigma$ are identified, they are used to train the final SVM model using fitcecoc.
This FIPSO-driven approach ensures robust convergence and improved generalization of the model, often outperforming manually-tuned or grid-searched SVMs by dynamically adapting particle velocities and positions based on both local and global optima in the search space.

MOPSO \cite{cui2022multi} to optimally tune the hyperparameter penalty parameter (C) and the kernel scale ($\sigma$) of an SVM. The MOPSO algorithm is designed to minimize multiple objectives simultaneously, which in this case are classification error and model complexity, by exploring a well-defined parameter space. The optimization process is driven by a swarm of 50 particles running for a maximum of 100 iterations. It is set up using MATLAB’s particle swarm function, leveraging parallel computation for efficiency. The objective function (moPsoObjectiveFunction) encapsulates the dual goals, typically trading off between achieving high classification accuracy and avoiding overfitting. Once the optimal Pareto-efficient parameters are obtained, they are used to train a multiclass SVM using fitcecoc with an RBF kernel, incorporating the best C and $\sigma$ as Box Constraint and Kerne lScale. This integration of MOPSO with SVM learning provides a robust and adaptive approach to hyperparameter tuning in classification tasks.
The initial preprocessing of the EEG data was followed by feature reduction using the FFT feature extraction technique. The classification of reduced features was performed using FIPSO, MOPSO and PSO optimized SVM. Our FIPSO yielded a score of 47.83\%, while our MOPSO score was 41.06\% and PSO+SVM achieved an accuracy of 99.37\%
\begin{figure}
    \centering
    \includegraphics[width=92mm,height=80mm]{img2.png}
    \caption{Electrode Placement of  14-channel EMOTIV EPOC+  }
    \label{emomodel}
\end{figure}

\section{GAMEEMO Dataset}

 The GAMEEMO data set\cite{alakus2020emotion} is an extensive emotion identification database derived from EEG signals, developed by Alakus et al. in the software engineering department of Firat University.
. In a game, emotions are driven primarily by the quadrants of the Arousal-Valence model. Negative emotions like 'angry' and 'bored' are on the left side of the valence dimension, while positive emotions like 'happy' and 'calm' are on the right. The upper dimension of arousal reflects high emotional or behavioral arousal, and the lower part indicates apathy. Therefore, emotions are classified into four quadrants: bored, calm, angry, and happy. As players interact with the game, they engage in high mental activity, processing images, forming narratives, and evaluating situations. Initially, emotions are not fixed to any specific quadrant. It involves 28 participants, aged 20 to 27 years, who were subjected to four computer games designed to elicit four basic emotions: boredom, calmness, horror, and amusement. Each game session lasted for 5 minutes, resulting in 20 minutes of EEG records per participant. The EEG signals were recorded using a 14 channel EMOTIV EPOC + EEG device, capturing 38,252 samples from each participant per game. The electrode positions are based on the 10-20 system and are shown in Figure \ref{emomodel}. Based on our findings, it appears that electrodes located in the frontal (Af3-Af4), occipital (O1-O2), and both hemispheres of the brain could potentially aid in categorization.
with the temporal (T7-T8) regions. Realizing that the feasibility of effective emotion recognition is challenging even with a single EEG channel was another focus of the study. In choosing the channel specifically, it was AF4 because earlier studies showed that the authors received the best results in terms of channel classification with AF4. We note that frequency range; Alpha (8 bands designated as 13 Hz, Delta (1-4 Hz) and Theta (4-8 Hz), in that sequence, are most strongly associated with different types of emotion.
  Additionally, each subject's ratings of the games are provided, using the Self-Assessment Manikin (SAM) form to assess arousal and valence levels. The games are labeled as G1, G2, G3, and G4, representing bore, calm, happy, and fun emotional stimuli. The GAMEEMO data set offers an alternative to traditional EEG data, showcasing the capabilities of portable and wearable EEG devices in emotion recognition studies. This data set is valuable for researchers looking to explore and improve emotion recognition techniques using EEG data.\begin{figure}
    \centering
    \includegraphics[width=90mm,height=65mm]{svmsnr11.png}
    \caption{SNR Before and After Denoising for 4 emotions}
    \label{snr}
\end{figure}

\begin{figure}[h]
    \centering
\includegraphics[width=90mm,height=65mm]{svmpsofprnew2.png}
    \caption{PSO based SVM methods F1 Score, Precision, and Recall for Each Subject }
    \label{fprrr}
\end{figure}

\begin{figure*}[h!]
    \centering
    \begin{minipage}{0.32\textwidth}
        \centering
        \includegraphics[width=\textwidth]{PSOSVM1.png}
     
    \end{minipage}
    \hfill
    \begin{minipage}{0.32\textwidth}
        \centering
        \includegraphics[width=\textwidth]{FIPSO.png}
      
    \end{minipage}
    \hfill
    \begin{minipage}{0.32\textwidth}
        \centering
        \includegraphics[width=\textwidth]{MOPSO.png}
     
    \end{minipage}
    
       
   \caption{PSO+SVM with 99.37\%, FIPSO+SVM with 57.83\% and FIPSO+SVM with 41.06\% Accuracy}
     \label{cone}
\end{figure*}


\begin{figure*}[h!]
    \centering
    \begin{minipage}{0.32\textwidth}
        \centering
        \includegraphics[width=\textwidth]{svmpsoaccloss1.png}
    
    \end{minipage}
    \hfill
    \begin{minipage}{0.32\textwidth}
        \centering
        \includegraphics[width=\textwidth]{svmpsoaccloss2.png}
       
    \end{minipage}
    \hfill
    \begin{minipage}{0.32\textwidth}
        \centering
        \includegraphics[width=\textwidth]{svmpsolossacc3.png}
       
    \end{minipage}
   \caption{Accuracy and Loss Convergence for Low Accuracy Model of PSO SVM, FIPSO+SVM and MOPSO+SVM}
   \label{lssacc}
\end{figure*}
\section{Results and Discussion}


\subsection{Evaluation Measures}


Assessment of emotion recognition using the PSO SVM classifier involves aspects such as performance indicators, estimating errors, and performing significance tests. Inception, the preprocessing stage required the calculation of signal-to-noise ratio (SNR) to obtain clear EEG signals. We employ Explainable Artificial Intelligence (XAI) techniques after identifying the essential features that originated from EEG data. The classifier used the features that were selected in this process. The confusion matrix, providing an overview of true and false classifications; precision, indicating the overall correctness of the classifier; precision, calculating the percentage of all positive predictions that are real positive identifications;  recall (sensitivity), which assesses how well the classifier can recognize each crucial instance;  the F1 score, which is the precision and recall mean; the average magnitude of prediction errors (MSE) is measured by the Root Mean Square Error (RMSE)
; and Cohen’s Kappa (K), evaluating the agreement between predicted and actual classifications adjusted for chance. Multiple metrics establish a thorough assessment method to predict the accuracy performance of PSO-SVM classifiers.



\subsubsection{Signal to Noise Ratio}


Figure \ref{snr} visualizes the improvement in Signal-to-Noise Ratio (SNR) before and after pre-processing using wavelet transform. It defines arrays for SNR values before and after pre-processing, indexed by subject. Using line plots, displays red circles for raw SNR and blue squares for processed SNR, highlighting improvements. SNR of denoised and undenoised EEG signals of four emotions of 18 subjects. The SNR plot of four emotions, the bore, calm, happy, and fun were analyzed and there was a marked enhancement in the SNR levels after denoising. In the bore emotion, the SNR before denoising was between -5 dB to -20 dB, then improved to -2 dB to -13 dB after denoising. In case of the calm emotion, the SNR values grew by -11 dB in comparison to -4 dB, prior to denoising and -11 dB to -1 dB, subsequent to denoising. On happy, the SNR achieved -3 dB to -19 dB before, to -1 dB to -12 dB after. In a similar way, SNR values in the fun emotion increased by 6dB to 22dB pre-to 2dB to 14dB post-denoising. Such findings also show that there is a steady increase in SNR, indicating that the denoising procedure has been effective in promoting the denoising process with various emotional states. In general, the findings affirm that the denoising procedure was successful in improving the quality of EEG signals among all the emotional states.

\begin{table}[h!]
\centering
\scriptsize
\caption{Performance Comparison of PSO, FIPSO and MOPSO on 4-class EEG Emotion Recognition}
\begin{tabular}{ c c c c c }
\hline
\textbf{Method} & \textbf{Class} & \textbf{Precision (\%)} & \textbf{Recall (\%)} & \textbf{F1-Score (\%)} \\ \hline
\multirow{}{}{PSO+SVM} 
& HANV & 99.5 & 100.0 & 99.8 \\ 
& HAPV & 98.0 & 98.0 & 98.0 \\ 
& LANV & 98.1 & 99.0 & 98.6 \\ 
& LAPV & 100.0 & 99.5 & 99.8 \\ \hline
\multirow{4}{*}{FIPSO+SVM} 
& HANV & 48.6 & 33.3 & 39.7 \\ 
& HAPV & 52.8 & 67.7 & 59.4 \\ 
& LANV & 100.0 & 100.0 & 100.0 \\ 
& LAPV & 100.0 & 28.0 & 43.8 \\ \hline
\multirow{4}{*}{MOPSO+SVM} 
& HANV & 48.0 & 24.0 & 32.0 \\ 
& HAPV & 51.2 & 76.8 & 61.5 \\ 
& LANV & 100.0 & 100.0 & 100.0 \\ 
& LAPV & 100.0 & 18.0 & 30.5 \\ \hline
\end{tabular}
\label{suma}
\end{table}






\subsubsection{F1 score Precision and Recall}

Figure \ref{fprrr} illustrates the F1 score, precision, and recall of the proposed method compared to those of other research studies.
 In the process of determining the effectiveness of the implementation of the proposed method to analyze human emotions with EEG signals, which are called True Positives or TP if they are accurately identified. whereby those that are wrongly classified as positive are referred to as False. Likewise, inaccurate negative effectivity implies that one is experiencing negative emotions that are not warranted. classified as negatives are True Negatives (TN), and those that are actually positive but are classified as negative are mentioned as False Negatives (FN).
F1 Score and recall is of 94 to 100 percent indicating high model accuracy overall in balancing precision and recall.
Precision values are within 93\%-100\% indicating that the model has high precision in positive emotional instances.
These small variations of performance between subjects can be explained by the inter-subject variability in the EEG but in general the model has high robustness to classification and generalization capacity. Table \ref{suma} Performance comparison of PSO, FIPSO, and MOPSO on 4-class EEG emotion recognition. The table shows   F1-score, precision, and recall, highlighting PSO’s enhanced performance compared to the relatively weaker results of FIPSO and MOPSO.

\begin{equation}
\text{F1 score} = 2 \times \frac{\text{Precision} \times \text{Recall}}{\text{Precision} + \text{Recall}}
\end{equation}

\begin{equation}
\text{Precision} = \frac{\text{TP}}{\text{TP} + \text{FP}}
\end{equation}

\begin{equation}
\text{Recall} = \frac{\text{TP}}{\text{TP} + \text{FN}}
\end{equation}


\subsubsection{Accuracy}
 
Figure \ref{cone} shows the results of the confusion matrix indicating that the PSO + SVM model achieved the highest classification accuracy of 99 37\%, reflecting strong predictive performance. In comparison, the FIPSO+SVM and MOPSO+SVM models obtained lower accuracies of 57.83\% and 41.06\%, respectively, suggesting reduced classification effectiveness and highlighting the superior performance of the PSO+SVM approach.

\begin{equation}
\text{Accuracy} = \frac{\text{TP} + \text{TN}}{\text{TP} + \text{TN} + \text{FP} + \text{FN}}
\end{equation}




Figure \ref{lssacc} illustrates the accuracy of training and testing and the loss convergence of the PSO-SVM, FIPSO + SVM and MOPSO + SVM models over 300 epochs. PSO-SVM achieves high accuracy (~99.37\%) with minimal loss. In contrast, FIPSO+SVM and MOPSO+SVM converge to lower accuracies (~57.83\% and ~41.06\%, respectively), with higher loss values, indicating relatively poor generalization and limited learning ability.

\subsubsection{RMSE and Kappa Factor}
In regression analysis, the RMSE is calculated by taking the square root of the arithmetic mean of the difference between predicted and observed values.
RMSE gives an indication of the best accuracy by the lower values shown in Table \ref{rmset}. RMSE values among emotions and indicates large errors between raw and filtered data (e.g., 16.3765 for Bore) as the result of noise. In contrast, RMSE between filtered and cleaned data is small (e.g., 0.0017 for Bore), noisy data have been removed, and the signal has been kept. This shows the effectiveness of the filtering and cleaning preprocessing steps.
 \begin{table}[h]
\centering
\scriptsize
\caption{RMSE Values of different emotions}
\begin{tabular}{p{2.2cm} p{1cm} p{1cm} p{1cm} p{1cm}}
\hline
\textbf{Data Comparison}                    & \textbf{Bore}   & \textbf{Calm}   & \textbf{Horror}   & \textbf{Fun}   \\ \hline
RMSE between raw and filtered data          & 16.3765       & 15.5903       & 15.2669       & 16.5054       \\ \hline
RMSE between filtered and cleaned data      & 0.0017        & 0.0032        & 0.0055        & 0.0149        \\ \hline

\end{tabular}
\label{rmset}
\end{table}
The Kappa factor(KF) measures the agreement between the observed and expected classifications while adjusting for possible agreement. Cohen introduced the Kappa factor as a metric to quantify the degree of agreement among two classifiers that had been shown in Figure \ref{kap}.
\begin{equation}
K = \frac{P_0 - P_e}{1 - P_e}
\end{equation}

 \(P_0\) is the observed agreement, denoted,

\begin{equation}
P_0 = \frac{TN + TP}{TN + TP + FP + FN}
\end{equation}


\begin{figure}[h]
    \centering
\includegraphics[width=80mm,height=65mm]{kappa2.png}
    \caption{Cohen Kappa factor }
    \label{kap}
\end{figure}



The expected agreement is categorized according to probability using the notation P. The sum of all possible probabilities of a random agreement is the total probability of a random agreement. they respond with either ‘Yes’ or ‘No’, that is, shown in the below equations. Analysis shows observed agreement (0.9617), expected agreement (0.2466) and Cohen Kappa (0.2516) and therefore demonstrates a significant difference between observed and expected agreement. The same tendency concerns another set of values: observed agreement (0.9617), expected agreement (0.2578), and Cohen s Kappa (0.2441), which also proves strong agreement of the model beyond chance agreement, although moderate Kappa values are observed.


\begin{equation}
P_e = P_{YES} + P_{NO}
\end{equation}

\begin{equation}
P_{YES} = \frac{FP + TP}{TN + TP + FP + FN} * \frac{FN + TP}{TN + TP + FP + FN}
\end{equation}

\begin{equation}
P_{NO} = \frac{FN + TN}{TN + TP + FP + FN} * \frac{FP + TN}{TN + TP + FP + FN}
\end{equation}







\begin{figure}[h]
    \centering
\includegraphics[width=90mm,height=65mm]{xai11++.png}
    \caption{ SHAP-mean
values across all samples for each class}
    \label{xa1}
\end{figure}

\subsection{SHAP Computation and Interpretability Insights}




The proposed work explains the process of generating SHAP-like values to determine the importance of features in the classification task using the SVM model. The process will start by declaring matrices for storing SHAP-like values for each of the samples and each of the features. For each feature, the test data are then modified by adding some random noise to the feature values, and then we predict again on the original and modified settings. The differences in the predictions are used to compute the SHAP-like contributions, and then the mean values across all samples are calculated for each class: boring, calm, horror, and funny. To analyze and interpret the results of these mean SHAP values, bar graphs and 3D bar graphs are used to show the significance of the features shown in Figure \ref{xa1} . 



Similarly, XAI employs random data to calculate and display SHAP values for explanation/visualization purposes, and the results are presented in different styles, such as scatter plots, heat maps, and feature importance bar plots. The derived solutions are presented in a 3D surface plot to find the best hyperparameter to help lower cross-validation errors, and the general descriptions of the interpretation and optimization of the model are shown in SHAP, LIME and PSO to design the SVM classification shown in Figure \ref{impps}. One of the visualization highlights that Feature 2 is the most important feature across all interpret ability methods (Feature Importance, SHAP, LIME), contributing significantly to the model's predictions. Feature 3, on the other hand, has minimal influence. Feature contributions vary across individual instances, demonstrating the model's sensitivity to specific data points. This comprehensive analysis ensures transparency within the decision-making model. Another visualization is performed by considering the features over 2000


\begin{figure}
    \centering
    \begin{subfigure}{\textwidth}
        \centering
\includegraphics[width=90mm,height=65mm]{xai33.png}
    \end{subfigure}
    \vspace{} % Adjust space between figures
    \begin{subfigure}{\textwidth}
        \centering
\includegraphics[width=90mm,height=65mm]{2000feasxai.png}
    \end{subfigure}
    \caption{ SHAP, LIME, and PSO in designing
SVM classification }
    \label{impps}
\end{figure}

\begin{figure}
    \centering
\includegraphics[width=90mm,height=65mm]{MSEPSO3.png}
    \caption{MSE: FIPSO, MOPSO, and PSO+SVM}
    \label{mse}
\end{figure}
\subsubsection{Comparative Analysis }
The MSE \cite{marmolin1986subjective} measures the average square difference between the actual and estimated values. It is used to compare three classifiers, where a lower MSE indicates better prediction accuracy and helps determine the most effective model for EEG signals. Figure \ref{mse} shows the simulated behavior of the MSE over 50 iterations for three optimization algorithms. FIPSO, MOPSO, and PSO+SVM. FIPSO reaches an MSE of 0.5217, MOPSO performs slightly worse with an MSE of 0.5894, while PSO+SVM maintains superior accuracy with a lower MSE of 0.0063. These values indicate that, despite the increasing trend, PSO+SVM is much more robust and stable in predictive accuracy compared to the other two methods. The inclusion of small random noise in the curves reflects natural fluctuations and adds realism to the simulated data.


\begin{figure}[h]
   % \centering
    \includegraphics[width=88mm,height=65mm]{FPR3.png}
    \caption{Comparison of different articles and datasets.}
    \label{apr}
\end{figure}
Figure \ref{apr} presents an evaluation that compares the F1 score, precision and recall of the suggested method with previous studies \cite{aung2022entropy}, \cite{wang2021review}, \cite{kamble2021ensemble}, \cite{khare2020time}, and \cite{jha2024emotion} . These results show how effective the suggested
approach improved performance in all three metrics. This comparison highlights the model's superior ability to balance precision and recall, thereby achieving better overall classification reliability and robustness. 

Therefore, the proposed PSO-SVM model was much better compared to traditional methods in classifying EEG signals. The accuracy achieved was considerably 99.37\%, and the confusion matrix revealed an improved classification in all emotional states. In addition, precision and recall, along with F1 scores, also confirmed that the model performs stably and maintains its processing capability. This is because EEG data are complex and noisy.

  
\section{Conclusion}
Our work represents EEG emotion classification on the GAMEEMO dataset. In this paper, we use four human emotions: boring, calm, horror, and funny. We focused our research on how machines interact with human emotion classes in order to classify them. This can be achieved by integrating advanced preprocessing techniques, feature extraction, data augmentation, and PSO for SVM optimization. The proposed methodology is an emotion identification with a classification accuracy of 99.37\%
tasks performed. The success of the PSO-SVM model confirms that optimization algorithms work as a key to improving the performance of the machine learning model for BCI applications. As a result, these findings can be useful in recognizing emotions in real time and helping to adapt machine responses during human–machine interactions. Still, there are many challenges, such as subject dependence and the restricted ability to generalize this work to other datasets.

Further research can extend the approach currently proposed in various ways.
To determine how cross-dataset results turn out, test the model with multiple EEG emotion datasets, such as DEAP and SEED.
Deep learning architectures are able to complete emotion recognition tasks by trying optimization strategies.
In general, research is a positive step in making BCI equipment more psychologically and adaptable.


\section{Author Contributions}
The research was conceived and designed collaboratively by all authors. Niharika Gudikandula contributed to the development of the topic, assisted in designing the literature search, and took primary responsibility for drafting and revising the manuscript for critical intellectual content. Ravichander Janapati conducted the methodology, performed data analysis, and contributed to the writing of specific sections of the manuscript. Sridhar Chintala contributed to the presentation of data, the creation of figures and tables, and the proofreading of the manuscript prior to final submission.






\section{Declarations}
\begin{itemize}
\item {\textbf{Study conduct in clinical trials}}: Not applicable
    \item{\textbf{Conflict of Interest}}:
The authors declare that they have no conflicts of interest of this work.
\item{ \textbf{Consent for publication}}: Not applicable
\item{\textbf{Ethics and Consent to Participate declarations}}: Not applicable.
\item{\textbf{Funding}}:
This research received no external funding.
\item {\textbf{Materials availability}: N/A
\item{\textbf{Data Availability}}:
The GAMEEMO data set used in this study is publicly available online.
\end{itemize}

\bibliographystyle{elsarticle-num} 

\bibliography{ref3}






\end{document}


%%
%% End of file `elsarticle-template-harv.tex'.
