Skip to main content
. 2020 Oct 9;22(10):1141. doi: 10.3390/e22101141
Algorithm 2: Hybrid learning classifier algorithm for classification of sleep stages.
  1. Inputs: Training feature matrix (Ftr∈RItr×q), training class label (Ltr∈RItr), test feature matrix (Fte∈RIte×q), number of nearest neighbors (nn), desired sparsity level (ρ).

  2. Output: Predicted class label, LP∈RIte

  3. Step 1: The training feature matrix Ftr is taken as a dictionary for the sparse representation of the test feature vector. The rth test instance fr can be written as fr=α1Ftr1+α2Ftr2+⋯⋯αeFtre [35]. where Ftre is the feature matrix for eth class. α1,α2,⋯⋯αe are the class-specific sparse representation vectors.

  4. Step 2: In this step, the combined sparse representation vector α=α1,α2⋯⋯αe is evaluated using the orthogonal matching pursuit (OMP) method as the optimization problem based on the fact that the minimization of L0-norm α=argminαα0 subjected to fr=αFtr is NP-hard [45].

  5. Step 3: The residual for the eth class is computed as Rese=fr−αeFtre2 [35].

  6. Step 4: In this step, the distances between fr and all training instances for the eth class are computed and these distances are given as dise(j)=fr−ftrje2. Then, the nearest distances for each class are selected. The median value of these distances for each class are evaluated, and they are given by De=mediandise1:nn, where nn is the number of nearest neighbors for each class.

  7. Step 5: The residual and distance for each class are summed up and the total distance (TD) is computed. The total distance for the eth class is given by TDe=Rese+De [35].

  8. Step 6: The distance vector is evaluated as TD=[TD1,TD2⋯⋯TDe]. The predicted class label for each feature vector in the test feature matrix is computed as lp=argmineTD [35]. For all test instances, the predicted class label vector is given as LP.