# A Two-Step Framework to Recognize Emotion Using the Combinations of Adjacent Frequency Bands of EEG
## 3 Methods
### The HCRC Method  
CRC_RLS [27] is an unsupervised classification method that searches a representation coefficient vector to combine the training set with the shortest representation distance and determines the classification results by the categories with the minimal regularized residual. As the data of different emotions are correlated, the regularized residuals of each category are relatively small. If the sample numbers in different categories are uneven, the dimension of the representation coefficient will be unequal when used to generate the regularized residual of each category, and the classification result will be influenced to some extent. To achieve better classification results, this paper proposes the HCRC method to randomly select (and reject simultaneously) some samples to keep the sample number of each category constant. Specifically, for a dataset of sample size \(N\), consider a training set \(X_{train}\) of a stimulus that has \(n\) categories. The subset of the \(i\)-th category is noted as \(X_{i}=\left[x_{i1},x_{2},\ldots,x_{in_{i}}\right]^{T}\in R^{n_{i}\times m}\), where \(x_{ij}\in R^{m\times 1}\) represents the \(j\)-th data of the \(i\)-th category with \(m\) elements, \(j=1,2,\ldots,n_{i}\) and \(i=1,2,\ldots,n\); then, the training set \(X_{train}\) can be expressed as \(X_{train}=\left[X_{1}^{T},X_{2}^{T},\ldots,X_{n}^{T}\right]^{T}\in R^{(\sum n _{i})\times m}\). As shown in Figure 2, the sample number \(l\) of the category with the minimum sample size in \(X_{train}\) is selected as the extraction number. For category \(X_{i}\), the simple random sampling method is used to sample \(l\) samples from it to compose the sampled data \(\widetilde{X}_{i}\), and the sampled data from each category are combined together to compose the extracted training set \(\widetilde{X}=\left[\widetilde{X}_{1}^{T},\widetilde{X}_{2}^{T},\ldots, \widetilde{X}_{n}^{T}\right]^{T}\in R^{nl\times m}\). Figure 2: The flow chat of HCRC. For a testing sample \(x\in R^{m\times 1}\), the representation distance from it to \(\widetilde{X}\) can be express as  
\[d=\parallel x-\widetilde{\widetilde{X}}^{T}\rho\parallel_{2}^{2}+ \lambda\parallel\rho\parallel_{2}^{2} \tag{1}\] \[=\parallel x-\sum_{i=1}^{n}\widetilde{X}_{i}\rho_{i}\parallel_{2}^ {2}+\lambda\sum_{i=1}^{n}\parallel\rho_{i}\parallel_{2}^{2}\]  
where \(\rho=\left[\rho_{1}^{T},\rho_{2}^{T},\ldots,\rho_{n}^{T}\right]^{T}\in R^{nl \times 1}\) are the representation vectors of \(\widetilde{X}\), \(\rho_{i}\in R^{l\times 1}\) is the representation coefficient of \(\widetilde{X}_{i}\), and \(\lambda\) is a regularization parameter. In Formula (1), the minimum value of the representation distance \(d\) can be calculated by the least squares estimation of \(\rho\), which can be expressed as  
\[\hat{\rho}=\underset{\rho}{\arg\max}\bigg{\{}\parallel x- \widetilde{\widetilde{X}}^{T}\rho\parallel_{2}^{2}+\lambda\parallel\rho \parallel_{2}^{2}\bigg{\}} \tag{2}\] \[=\bigg{(}\widetilde{X}\widetilde{X}^{T}+\lambda I\bigg{)}^{-1} \widetilde{X}x\]  
where \(\hat{\rho}\in R^{nl\times 1}\) can be written as \(\hat{\rho}=\left[\hat{\rho}_{1}^{T},\hat{\rho}_{2}^{T},\ldots,\hat{\rho}_{n}^ {T}\right]^{T}\), where \(\hat{\rho}_{i}\in R^{l\times 1}\) is the estimated representation coefficient of \(\widetilde{X}_{i}\). Thus, the regularized residual of category \(\widetilde{X}_{i}\) (\(i=1,2,\ldots,n\)) would be expressed as  
\[e_{i}=\parallel x-\widetilde{\widetilde{X}}_{i}^{T}\hat{\rho}_{i}\parallel_{2 }/\parallel\hat{\rho}_{i}\parallel_{2} \tag{3}\]  
Each category has a regularized residual \(e_{i}\), and the category with the minimum regularized residual is the classification result of the HCRC method. For each sampled \(\widetilde{X}_{i}\), under certain sparsity constraints, \(\widetilde{X}_{i}\) only needs a small number of samples to represent \(x\), which proves that the imbalance of samples has little effect on the classification results.