|
Algorithm 1 CNN-LSTM-GA: Feature selection and hyperparameter optimization |
Input: D—Dataset, —population size, —number of generations, —crossover probability, —mutation probability
Output: Best individual and corresponding CNN-LSTM model
-
1:
Split D into train (40%), validation (40%) and test (20%) subsets;
// Initialize population P with individuals
-
2:
for each individual do
-
3:
Randomly initialize feature subset and model hyperparameters ;
-
4:
end for
-
5:
for generation = 1 to do
-
6:
for each individual do
-
7:
Decode chromosome → feature subset and model hyperparameters ;
-
8:
Build CNN-LSTM();
-
9:
Construct and datasets from EEG data using feature subset ;
-
10:
Train CNN-LSTM() model with ;
-
11:
Compute fitness as the F1-score of CNN_LSTM() evaluated on ;
-
12:
end for
-
13:
Apply tournament selection to choose parents based on ;
-
14:
For each parent pair, generate two offspring using crossover with probability .
-
15:
for each offspring gene g with probability do
-
16:
if g is Boolean then
-
17:
Flip gene g;
-
18:
else if g is Integer or Real then
-
19:
Apply window mutation;
-
20:
else if g is Nominal then
-
21:
Replace with random category;
-
22:
end if
-
23:
end for
-
24:
Form new population P combining best individuals and offspring;
-
25:
end for
-
26:
Select best individual ;
-
27:
Decode individual → feature subset and model hyperparameters ;
-
28:
Build CNN-LSTM();
-
29:
Construct and datasets from EEG data using feature subset ;
-
30:
Train CNN-LSTM() model with ;
-
31:
Evaluate final model on ;
-
32:
return
|