Comparison of Different Machine Learning Algorithms to Classify Epilepsy Seizure from EEG Signals

: Recurrent seizures are a symptom of a central nervous system disease called epilepsy. The duration of these seizures lasts less than a few seconds or sometimes minutes. There are very few ways to record seizures, and one of them is EEG. EEG systems mainly consist of scalp electrodes that record electrical activity. These EEG data are often complex signals containing noise and artifacts. Accurate classiﬁcation of epileptic seizures is a major challenge, as manual seizure identiﬁcation is a laborious and challenging endeavor for neurologists. An automated method for seizure detection and categorization was required to address this issue. In this paper, we used machine learning and proposed a model that predicts the behavior of these signals and classiﬁes seizures. The Epileptic Seizure Recognition Data Set from the UCI Machine Learning Repository was the dataset used in this work. The model is evaluated on various models such as XGboost, Extra Tree Classiﬁer, Random Forest, etc. Using measures like F1 score, recall, and precision, the proposed approaches have been assessed. The results indicate that Random Forest produced the superior result of 0.943 F1 score, and XGB achieved a slightly lower F1 score of 0.933. Moreover, Random Forest has the highest accuracy of 0.977.


Introduction
In the present years, the brain-computer interface with clever signal decomposition has played a major role in the fields of medicine, defense services, etc. [1].It is desirable to have a skilled approach to feature extraction from EEG signals that will make braincomputer interface building easier.The communication between neurons in the brain takes place using electrical signals.The brain activities of living beings are based on these electrical signals.At some point, a failure to communicate causes a brain seizure [2].The electroencephalogram (EEG) data reveal the brain's electrical activity.Epilepsy, for instance, can be identified by examining the EEG waves [3].Seizures are characterized by abnormal brain activity brought on by an epileptic disturbance that interferes with normal brain or body function and affects the central nervous system.The neurological condition epilepsy is characterized by repeated seizures, which are short (lasting less than minutes) bursts of uncontrollable movement that can affect one or all body parts and are occasionally followed by loss of consciousness and control over bowel or bladder function.High electrical performance in a bunch of cerebrum chambers is the result of seizures.Such discharges can occur in many areas of the brain.Muscle jerks used to prolong seizure episodes might be different in seizures.The frequency of seizures also varies.The progressive neurobiological process, known as "epileptogenesis", is the cause Eng.Proc.2023, 59, 166 2 of 9 of epilepsy.Its signs include disorientation, strange behavior, and awareness loss [4].These symptoms can lead to injury from falls or tongue-biting.
A WHO survey notes that almost 7 million of the globe's population have seizures, leading to the most common neurological disease [5].It could be difficult to predict when someone could experience a seizure.Therefore, we can say that an epileptic seizure is a dangerous disorder, as it is not inculcated when it arrives.So, for this reason, EEG signals play a major role in the detection of epileptic disorders.To diagnose and conduct a thorough investigation of the brain during an epileptic seizure event, electroencephalography (EEG) is useful.The study of epilepsy recovery strategies involves utilizing EEG, a technique that examines non-Gaussian and non-stationary signals representing electrical activity in the brain.These signals are employed to detect various types of brain disorders [6].
In [7], the authors proposed a fusion approach using deep learning.They used a multi-modal approach for each data stream.And the method uses ensemble fusion on the outputs.EEG waves are written down using the metal plates attached to the scalp.There are several channels that collect brain activity using these electrodes.The physical placement of these electrodes is followed by the International 10-20 systems, as shown in Figure 1.signs include disorientation, strange behavior, and awareness loss [4].These symptoms can lead to injury from falls or tongue-biting.
A WHO survey notes that almost 7 million of the globe's population have seizures, leading to the most common neurological disease [5].It could be difficult to predict when someone could experience a seizure.Therefore, we can say that an epileptic seizure is a dangerous disorder, as it is not inculcated when it arrives.So, for this reason, EEG signals play a major role in the detection of epileptic disorders.To diagnose and conduct a thorough investigation of the brain during an epileptic seizure event, electroencephalography (EEG) is useful.The study of epilepsy recovery strategies involves utilizing EEG, a technique that examines non-Gaussian and non-stationary signals representing electrical activity in the brain.These signals are employed to detect various types of brain disorders [6].
In [7], the authors proposed a fusion approach using deep learning.They used a multi-modal approach for each data stream.And the method uses ensemble fusion on the outputs.EEG waves are written down using the metal plates attached to the scalp.There are several channels that collect brain activity using these electrodes.The physical placement of these electrodes is followed by the International 10-20 systems, as shown in Fig- ure 1.Although there are many models in earlier papers, the detection of seizures can still be improved.In this research, we build on the previous work and explore the viability of employing machine learning methods for automatically classifying seizures.Epileptic Seizure Recognition is the dataset used in this model.The origin of this dataset can be traced back to the UCI Machine Learning Repository.The model is evaluated on various models such as XGboost, Extra Tree Classifier, Random Forest, etc.Using measures like the F1 score, recall, and precision, the proposed approaches were assessed.The F1 score was considered as the evaluation factor as the dataset was mostly imbalanced.The detailed methodology of the model is explained further in the paper.

Materials
The points addressed in this section are the dataset used, data pre-processing techniques, and machine learning classification algorithms that were explored.
Before jumping into further analysis and classification, there is one thing that is very crucial in any machine learning research.Good and clean data have no substitute.This research focuses on detecting epileptic seizures from multichannel electroencephalogram signals.Often, EEG signals contain various noises and artifacts, and to detect the occurrence of seizures, the collected data need to be clean, as it reflects brain activity and important electrical impulses [8].The EEG records the continuous electrical impulses in the Although there are many models in earlier papers, the detection of seizures can still be improved.In this research, we build on the previous work and explore the viability of employing machine learning methods for automatically classifying seizures.Epileptic Seizure Recognition is the dataset used in this model.The origin of this dataset can be traced back to the UCI Machine Learning Repository.The model is evaluated on various models such as XGboost, Extra Tree Classifier, Random Forest, etc.Using measures like the F1 score, recall, and precision, the proposed approaches were assessed.The F1 score was considered as the evaluation factor as the dataset was mostly imbalanced.The detailed methodology of the model is explained further in the paper.

Materials
The points addressed in this section are the dataset used, data pre-processing techniques, and machine learning classification algorithms that were explored.
Before jumping into further analysis and classification, there is one thing that is very crucial in any machine learning research.Good and clean data have no substitute.This research focuses on detecting epileptic seizures from multichannel electroencephalogram signals.Often, EEG signals contain various noises and artifacts, and to detect the occurrence of seizures, the collected data need to be clean, as it reflects brain activity and important electrical impulses [8].The EEG records the continuous electrical impulses in the form of signals, and it records the abnormal electrical activity that leads to seizures.Therefore, the first step is always to find the correct dataset [9].In this paper, we studied various epileptic seizure databases that were released by various research institutes around the world.There are mainly 6 datasets that we have included in our analysis, considering different factors that our research primarily needs.Table 1 contains an overview of the datasets available publicly.Although multiple databases are widely available, we focused on a few parameters that we needed in our study, such as sampling rate.It is one of the necessary parameters when it comes to EEG signals.As the human brain is functioning constantly, the generated voltages are fluctuating continuously, and on the other hand, EEG systems produce samples of data by taking discrete photos of this ongoing activity, much like a camera would do.Various EEG systems have different sampling rates, indicating the number of samples they can capture per second.Like oscillations, the unit of the sampling rate is also samples per second, which is also called Hertz (Hz).For instance, a 250 Hz sampling rate EEG equipment may record 250 samples per second.Hence, the higher the sampling rate is, the better would be the precision of signals.The highest frequency in an EEG signal that may be studied is equal to half of the sampling rate.Only consider frequencies up to 256/2 = 128 Hz, for example, if your data were collected at 256 Hz.Research that is even more focused suggests staying with frequencies that are roughly onethird the sampling rate (for example, 256/3 = 85.3Hz).Since the brain typically generates lower frequencies, you can be certain that the results will be clear even with low EEG sampling rates of roughly 100 Hz (for example, gamma between [25-80 Hz] and delta between [1-4 Hz]).This model utilized the Epileptic Seizure Recognition Data Set sourced from the UCI Machine Learning Repository.In the original dataset, there were 100 files per folder, each of which represented a distinct subject or individual.In each file, there is a recording of brain activity lasting 23.6 s.The associated time series comprises 4097 sampled data points, each indicating the EEG record's value at a particular moment in time.Therefore, the data consist of a total of 500 individuals, each of whom has 4097 data points collected during 23.5 s.Every data point represents the EEG recording value at a distinct moment, as each 23-unit chunk contains 178 data points per second, randomly distributed within the 4097 data points.Therefore, 23 × 500 = 11,500 rows of informational elements make up the data, with the last column serving as the output label.In each row, there are 178 data points, corresponding to a duration of 1 s.The dataset comprises 2300 instances of EEG signals with seizures and 9200 instances of EEG signals without seizures.Due to this imbalanced nature of the dataset, the F1 score, recall, and precision were chosen as the performance metrics.Table 2 gives the description of the dataset.

Class Name Class Label Number of Instances
Epileptic Seizure 1 2300 Non-Seizure 0 9200

Pre-Processing
The proposed model's progression is illustrated in Figure 2. The initial stage involves data pre-processing, wherein standardization is carried out.Subsequently, classification algorithms are employed to distinguish between epileptic seizure and non-seizure conditions.

Class Name Class Label Number of Instances
Epileptic Seizure 1 2300 Non-Seizure 0 9200

Pre-Processing
The proposed model's progression is illustrated in Figure 2. The initial stage involves data pre-processing, wherein standardization is carried out.Subsequently, classification algorithms are employed to distinguish between epileptic seizure and non-seizure conditions.To avoid overfitting, any machine learning model must go through a crucial step where the data are split into two halves [10].One for testing, the other for training.Hold out cross validation is a technique where the data are divided into a train test set.After trying different combinations of train and test size, this system appeared to exhibit improved performance when utilizing a 70-30 split, meaning 70% of the data were allocated for training and 30% for testing.
The model fitting and model learning functions are not equally affected by variables assessed at different scales, and they may even lead to bias.The idea is to standardize the features individually (mean = 0 and standard deviation = 1).
For classification, we have used algorithms such as k-Nearest Neighbor (KNN), Naive Bayes, Random Forest, Gradient Boost, Extreme Gradient Boost (XGB) and Extra Tree Classifier (ETC).For all these classifiers, a train-test split ratio of 70-30 was chosen.To avoid overfitting, any machine learning model must go through a crucial step where the data are split into two halves [10].One for testing, the other for training.Hold out cross validation is a technique where the data are divided into a train test set.After trying different combinations of train and test size, this system appeared to exhibit improved performance when utilizing a 70-30 split, meaning 70% of the data were allocated for training and 30% for testing.
The model fitting and model learning functions are not equally affected by variables assessed at different scales, and they may even lead to bias.The idea is to standardize the features individually (mean = 0 and standard deviation = 1).
For classification, we have used algorithms such as k-Nearest Neighbor (KNN), Naive Bayes, Random Forest, Gradient Boost, Extreme Gradient Boost (XGB) and Extra Tree Classifier (ETC).For all these classifiers, a train-test split ratio of 70-30 was chosen.

Machine Learning Classification Models 2.3.1. K-Nearest Neighbor
KNN is the supervised machine learning algorithm capable of serving purposes in both classification and regression tasks.The outcome of KNN is c class membership.The class to which an object should belong is determined by the majority of votes of k nearest neighbors [11].The positive integer k is typically small and mostly odd.The KNN model is fitted to the training and validation set with the value of k as 3.The distance metric used was Minkowski distance of order 2 and rest parameters as default.The minkowski distance between two points X = (x 1 , x 2 , . . . ,x n ) and Y = (y 1 , y 2 , . . . ,y n ) is given by: As order of two is used in the algorithm, then the Minkowski distance becomes the Euclidean distance.

Naive Bayes
It relies on the principles of Bayes theorem and hence utilizes probability for dependent variables.It is assumed that every independent variable has an independent and equal contribution to the outcome [12].The parameters of NB were kept default and for better prediction.

Random Forest
Random Forest combines the result of decision trees to give better accuracy.Here parallel trees are bagged or aggregated we can say, so it is a bagging or bootstrap aggregation ensemble learning algorithm with base learner as decision trees.It constructs and integrates various decision trees to improve accuracy.names random and forest refer to the random selection of predictors and the usage of a variety of decision trees in prediction and decision-making.Through its features, random forest aids in preventing overfitting and strengthens the model.The model uses 100 estimators with Gini as the criterion [13].
where, f i = frequency of node, C = number of distinct labels.

Gradient Boost
It is a widely used boosting algorithm which uses Classification and Regression Trees as its base learner.It consists of n trees in which the first tree is randomly trained.Then, the next tree is given residual or errors of the first tree with preceding dataset and a similar pattern continues until all N trees forming ensembles are trained.It trains the base learners(trees) sequentially, that is models are trained one after the other.The model uses 100 boosting rounds.To increase the learning capability of the model, a learning rate of 1.0 was used.These two parameters are the hyperparameters of the gradient boost algorithm on which the performance of the model depends [14].Other parameters such as max depth and random state were 3 and 69, respectively.This algorithm proved to be one of the best among all in predicting the seizures.This model keeps updating the predictions of previous models in the next model.Let us assume a gradient boost model with M stages.At each stage m such that (1 ≤ m ≤ M), there is an unreliable model F m , so the model adds some new estimators h m (x), In this way, the gradient boost model corrects the errors of its predecessor model in the successor.

Extreme Gradient Boost
This is an ensemble modelling technique of boosting type.It is faster than gradient boosting as regularization techniques, that is L1(Lasso) and L2(Ridge) Regularization.Weights are assigned to independent variables and then given to the decision tree which then increases the weight of wrongly assigned variables before going to the next decision Eng.Proc.2023, 59, 166 6 of 9 tree to improve accuracy of the model.It minimizes the bias and the penalizing of trees is conducted very cleverly.It has gained much popularity in recent times as it is the choice of many data scientists [15].This algorithm uses the Newton-Raphson function space unlike gradient descent boosting that uses gradient descent function space.

Extra Tree Classifier
Extra Tree Classifier is pretty like the random forest classifier, with the building of the decision trees in the forest being the sole difference.Multiple de-correlated decision trees are formed using calculations based on Gini index or information gain and entropy.This very random tree classifier is another example of an ensemble learning technique.In this, 100 estimators were used [16].The criterion was entropy and max features as 1.0.Minimum leaf samples were 3 and minimum sample split was 20.This model does not use bootstrap that means the samples of trees are made without replacement unlike Random Forest which uses bootstrap.Another difference between extra tree classifier and random forest is that extra trees use random splits of nodes unlike random trees which use best splits.
In the above formula, c stands for unique class labels and p i stands for the ratio of rows with output labels.

Performance Metrics
After analyzing the data, it was found that the data is biased towards the baseline class.Prevalence of seizure class is just 20% in the whole dataset which says that the dataset is mostly imbalanced.Hence it would not be wise to use accuracy as a performance indicator.Therefore, the F1 score is used to evaluate the classification models [17].The F1 score is a metric that represents the harmonic mean of precision and recall, providing a more balanced summary of the model's performance.
The F1 score in terms of components of confusion matrix can be given as follows:

Results and Discussion
The EEG signals are complex in nature and difficult to extract; they often contain a lot of noise, and the reduced availability of EEG data makes it difficult for researchers to study.Numerous datasets exist in various forms, but extracting the EEG signals is often a complicated task.The training data has been fed to several classifiers for the classification of seizures.Dealing with large amounts of data seemed to be one of the major challenges [18].
To assess the overall performance of classifiers, the UCI dataset is experimented with various classification models.To validate the proposed method, 30% of the dataset is allocated for training, while the remaining 70% is utilized for testing.As the dataset was unbalanced, instead of accuracy, the F1 score was calculated as a performance metric for all of the classifiers.In Figure 3, it is clear that Random Forest (RF) and Extreme Gradient Boost (EGB) achieved the highest F1 score for both training and testing.Other classifiers, such as KNN, Naive Bayes, and Gradient Boost, achieved the F1 score less than Random Forest and ETC.The accuracy, the F1 score, precision and recall of the entire classification are summarized in Table 3.For this binary classification, confusion matrices were plotted for visualization purposes.
unbalanced, instead of accuracy, the F1 score was calculated as a performance metric for all of the classifiers.In Figure 3, it is clear that Random Forest (RF) and Extreme Gradient Boost (EGB) achieved the highest F1 score for both training and testing.Other classifiers, such as KNN, Naive Bayes, and Gradient Boost, achieved the F1 score less than Random Forest and ETC.The accuracy, the F1 score, precision and recall of the entire classification are summarized in Table 3.For this binary classification, confusion matrices were plotted for visualization purposes.When examining the output generated by the classifier models based on the F1 score, the lowest F1 score, which is 0.768, was attributed to the KNN model, whereas Gradient Boost reached a higher F1 score of 0.889.On the other hand, Random Forest outperformed all of the models and achieved an F1 score of 0.943.Eventually, the accuracy study of specified models showed that Random Forest performed better than others, with a maximum accuracy of 0.977, whereas Extreme Gradient Boost and Extra Tree Classifier achieved slightly lower accuracy of 0.974 and 0.973, respectively.Other performance metrics, such as recall, precision and specificity, of all of the classifiers are depicted in Table III.

Conclusions
These EEG data are often complex signals containing noise and artifacts.Accurate classification of epileptic seizures is a major challenge, as manual seizure identification is a laborious and challenging endeavor for neurologists [19].This work aimed to develop a potent machine learning model that could forecast when epileptic seizures will occur.This study utilized the Epileptic Seizure Recognition Data Set sourced from the UCI Machine Learning Repository.Standardization was applied during the data pre-processing phase.When examining the output generated by the classifier models based on the F1 score, the lowest F1 score, which is 0.768, was attributed to the KNN model, whereas Gradient Boost reached a higher F1 score of 0.889.On the other hand, Random Forest outperformed all of the models and achieved an F1 score of 0.943.Eventually, the accuracy study of specified models showed that Random Forest performed better than others, with a maximum accuracy of 0.977, whereas Extreme Gradient Boost and Extra Tree Classifier achieved slightly lower accuracy of 0.974 and 0.973, respectively.Other performance metrics, such as recall, precision and specificity, of all of the classifiers are depicted in Table 3.

Conclusions
These EEG data are often complex signals containing noise and artifacts.Accurate classification of epileptic seizures is a major challenge, as manual seizure identification is a laborious and challenging endeavor for neurologists [19].This work aimed to develop a potent machine learning model that could forecast when epileptic seizures will occur.This study utilized the Epileptic Seizure Recognition Data Set sourced from the UCI Machine Learning Repository.Standardization was applied during the data pre-processing phase.
Seizure and non-seizure activity were classified using several models, including Random Forest, K-nearest neighbor, naïve bayes, gradient boost, extra tree classifier and extreme gradient boost [20].To validate the aforementioned models, 30% of the dataset is employed for training, while the remaining 70% is utilized for testing.As the dataset was imbalanced, instead of accuracy, the F1 score was calculated as a performance metric for all classifiers.The results show that Random Forest and Extreme Gradient Boost achieved the highest F1 score of 0.943 and 0.933, respectively.An accuracy of 0.977 was given by Random Forest, which was the highest among all.On an average, 97% accuracy was shown by all the algorithms.

Figure 3 .
Figure 3. F1 score graph of all classifiers for training and testing set.

Figure 3 .
Figure 3. F1 score graph of all classifiers for training and testing set.

Table 2 .
Description of the dataset.

Table 2 .
Description of the dataset.

Table 3 .
Result analysis of Classifiers.

Table 3 .
Result analysis of Classifiers.