## 3 Proposed Method
### Cognitive Emotion Recognition Using Active Learning Based on Complexity and Uncertainty
#### 3.4.2 The Active Learning Algorithm Based on Uncertainty and Complexity  
This paper proposes an active learning algorithm based on uncertainty and complexity. The process and pseudo-code of this algorithm are shown in Figure 5 and Algorithm 1. First, the dataset is represented by \(D\) and divided into two parts: labeled dataset \(D_{1}\) and unlabeled dataset \(D_{\text{u}}\). In the initialization section, the labeled dataset \(D_{1}\) is used to train the RF model \(f\). In the loop section, the prediction probabilities of each of the 4 cognitive  
Figure 5: The flow diagram of the active learning algorithm based on uncertainty and complexity. emotions can be obtained through model \(f\). According to Formula (18), the _UN_ values of all the samples belonging to \(D_{\text{u}}\) can be calculated, and the \(h\) of the most uncertain samples can be selected according to the following formula:  
\[D_{\text{h}}=\text{argmax}(\textit{UN}(x_{i})),\ x_{i}\in D_{\text{u}} \tag{20}\]  
where \(D_{\text{h}}\) represents the top \(h\) samples in dataset \(D_{\text{u}}\), sorted by uncertainty values. Then, the following formula is used to calculate the complexity of all the samples in \(D_{\text{h}}\) and obtain the most representative sample \(x^{*}\). \[x^{*}=\text{argmin}(CO(x_{i})),\ x_{i}\in D_{\text{h}} \tag{21}\]  
Finally, the label \(y^{*}\) is manually added to the selected sample \(x^{*}\) and it is moved from dataset \(D_{\text{u}}\) to dataset \(D_{1}\) to update the RF classifier model \(f\). This loop is executed until the number of selected samples is reached. ```
Input:  Dataset \(D\) Initialize:
1: Divide \(D\) into \(D_{1}\) and \(D_{\text{u}}\);
2: Train the RF model \(f\) on \(D_{1}\). Loop:
3: Obtain predictions and labels for samples in \(D_{\text{u}}\) with \(f\);
4: Compute \(\textit{UN}(x)\) for all \(x\in D_{\text{u}}\);
5: Select the first \(h\) samples with the largest uncertainty and compose \(D_{\text{h}}\);
6: Compute \(CO(x)\) for all \(x\in D_{\text{h}}\);
7: Select the sample \(x^{*}\) with minimum \(CO\) value;
8: Manually add the labels \(y^{*}\) for \(x^{*}\);
9: Move \(x^{*}\) from \(D_{\text{u}}\) to \(D_{1}\);
10: Update the RF model \(f\) with the updated \(D_{1}\). Until the number of selected samples is reached. ```  
**Algorithm 1**The pseudo-code of the active learning algorithm based on uncertainty and complexity. The purpose of the algorithm is to make the classification boundary clear with the lowest cost of labeling. This algorithm continuously searches for the most valuable samples and updates and optimizes the classifier. Under the condition that the computer (Hewlett-Packard Z1, from Palo Alto, CA, USA) uses a configuration of Windows 10, 11 th Gen Intel(R) Core(TM) i7-11700 @ 2.50 GHz, Intel(R) HUD Graphics 750, and NIVIDIA GeForce RTX3070, with a labeled sample size of 80 and an unlabeled sample size of 820, h was set to 4. The average time to finish one round of sample selection (including retraining the RF model) for the proposed feature extraction method and feature vectors was 6.7 s. On the surface, we did sacrifice some time to screen the samples. However, due to the fact that this method may only require labeling for 50% of the samples to achieve a similar classification accuracy, it saves a lot of time in labeling the samples. 3.4.3. The Method of Cognitive Emotion Recognition Based on Active Learning  
This section serves as a summary of the entire method framework. The steps of the emotion recognition method based on the active learning algorithm proposed in this paper is shown in Algorithm 2. ```
1:Input:
2:Dataset \(D\)
3:Initialize:
4: Trim and capture key parts from video;
5: Track and locate facial emotion points using AAM;
6: Extract cognitive emotion features (geodesic distance and sample entropy);
7: Divide \(D\) into \(D_{1}\) and \(D_{u}\).