## 3 Methods
### Methods
#### 3.3.2 Method 2 (MDRM plus PCA)  
Method 2 extends the approach used in method 1 by incorporating dimensionality reduction through PCA. This stage includes feature selection to improve accuracy by eliminating irrelevant features, reducing noise, and mitigating overfitting, resulting in a more robust and generalizable model.  
Figure 2: Block diagram of proposed EEG-based emotion classification method using Riemannian geometry.  
3.3.3. Method 3 (MDRM plus PCA plus Hyperparameter Tuning)  
Method 3 builds upon the foundation of method 2 as mentioned earlier. Specifically, method 3 incorporates hyperparameter tuning to optimize the performance of the classification model. The approach evaluates the model with 20 hyperparameter combinations, consisting of 5 frequency bandwidths (theta, alpha, beta, gamma, and all) and four threshold values for principal components. The proposed method assigns each test trial a unique set of hyperparameters based on the dataset's characteristics during the validation process. This approach is illustrated in Algorithm 3 and is expected to exhibit superior classification accuracy compared to method 1 and 2. In addition to utilizing the MDRM algorithm and PCA, hyperparameter tuning was introduced in this study. Selecting the frequency band and threshold to determine the components required to explain a certain percentage of the total variation in the PCA process results in the number of feature vectors used for classification, which depends on the threshold chosen for each test trial.  
The hyperparameter selection process is achieved using inner and outer leave-one-out cross-validations (LOOCV). The inner cross-validation loop evaluates the hyperparameter combinations by taking a validation trial and measuring each hyperparameter combination's classification accuracy. The highest accuracy of the hyperparameter combination is applied for each test trial within the outer cross-validation loop. The procedure for selecting hyperparameter combinations involved identifying the frequency band with the highest accuracy across all thresholds, followed by selecting the highest threshold within that band within the inner cross-validation to ensure no overfitting occurs. For each test trial, feature vectors were pre-processed using the optimal hyperparameters, and the covariance matrix form for each trial was computed. The mean of each class was then calculated using the Riemannian mean algorithm, as shown in Algorithm 1[42].  
```
1:\(k1\) = outer folds, \(k2\) = inner folds.
2:\(D\), the subject dataset.
3:\(p_{i}^{pair}\), hyperparameters pairs.
4: Accuracy
5:for\(i=1\to k1\)do
6: Split \(D\) into \(D_{i}^{train}\), \(D_{i}^{test}\) for the \(i\)-th split
7:for\(p\in P_{i}^{pair}\)do
8:for\(j=1\to k2\)do
9: Split \(D_{i}^{train}\) into \(D_{j}^{train}\), \(D_{j}^{val}\).
10: Apply BPF (\(\theta,\alpha,\beta,\gamma\)).
11: Apply PCA.
12: Compute \(\hat{\Sigma}_{i}\) of \(X_{i}\).
13: Compute \(\Sigma_{\mu}^{(k)}\) in Algorithm 1.
14: Predict \(\hat{k}\) in Algorithm 2.
15:Return \(\hat{k}\).
16:endfor
17: Compute the accuracy with \(D_{j}^{test}\).
18:endfor
19: Select the optimal hyperparameter combination and apply it to \(D_{i}^{test}\).
20: Predict \(\hat{k}\) using \(D_{i}^{test}\) in Algorithm 2.
21:% \(\hat{k}\) is the predicted class of the test trial.
22:endfor
23:return Accuracy
```  
**Algorithm 3** Feature extraction and hyperparameter tuning.