# Sleep Posture Recognition Method Based on Sparse Body Pressure Features
## 4 Methodology
### Selection of Base Learners  
Presently, in the realm of ensemble learning, the predominant method for base-learner selection is the entropy-weighted score [32]. However, this approach solely identifies the base learner with superior overall performance and does not adequately capture the complementary capabilities among base learners in ensemble learning. Consequently, we offer a novel evaluation metric, the complementarity score, to identify base learner models that are complementary to it after the entropy-weighted score has filtered the high-quality base learner models, aiming to develop a superior ensemble learning model. During the preliminary selection step of base learners, we integrate four assessment metrics (Accuracy, F1, AUC, and Kappa) to identify the most appropriate base learners. The candidate base learners include Logistic Regression (LR) [41], Naive Bayes (NB) [42], Decision Tree (DT) [43], KNN [44], RF, Support Vector Machine (SVM) [45], XGBoost, and Gaussian Process(GP) [46]. By calculating the entropy-weighted scores of each base learner, as illustrated in Figure 5, SVM and RF exhibited superior overall performance, achieving entropy-weighted scores of 25.53 and 24.83, respectively. The Decision Tree and KNN models, exhibiting lower entropy-weighted scores, contributed less to the overall efficacy of the sleeping posture classification task and were hence eliminated from the upcoming investigation. To further optimize the ensemble learning model, we computed the complementarity scores between the remaining candidate base learners and the two high-performing base learners, SVM and RF. The criterion for computing the complementarity score integrates Accuracy, the Kappa coefficient, and the overlap of misclassified samples, applying a weighting ratio of 1:1:3 to emphasize the complementary characteristics among the models. Figure 6 illustrates that SVM and XGBoost exhibit the highest complementarity scores; RF and GP also demonstrate notable complementarity scores. Consequently, we ultimately selected two combinations of base learners, SVM + XGBoost and RF + GP, to enhance the performance and stability of ensemble learning. The entropy-weighted composite score (\(EWS_{i}\)) and complementarity score (\(C_{ab}\)) are calculated as follows:  
\[EWS_{i}=\sum_{j=1}^{n}\frac{\text{score}_{ij}}{H_{i}+\epsilon} \tag{13}\]  
\[overlap_{ab}=\frac{|errors_{a}\cap errors_{b}|}{|errors_{a}\cup errors_{b}|} \tag{14}\]  
\[C_{ab}=w_{1}\cdot(acc_{a}+acc_{b})+w_{2}\cdot(0-\kappa_{ab})+w_{3}\cdot(1- overlap_{ab}) \tag{15}\]  
where score\({}_{ij}\) is the score of the model on the jth metric, \(H_{i}\) is the entropy value of model \(i\), \(\epsilon\) is a small constant, \(w_{1}\), \(w_{2}\), \(w_{3}\) is the weight of each metric, \(|errors_{a}\cap errors_{b}|\) represents the size of the intersection of error samples between the two models, and \(|errors_{a}\cup errors_{b}|\) represents the size of the concatenation of error samples among the two models. Figure 5: Entropy-weighted scores for each base learner. The confusion matrix in Figure 7 shows the results for the two most efficient classifiers and their results after soft voting with the integration of the complementary models. It can be seen that RF and SVM are less accurate for supine, cross-legged supine, supine, and edge sleepers; however, these deficiencies are clearly strengthened after soft voting with the supplementary model. Although there was a slight attenuation of some of the dominant terms, it was not significant. To more fully capture the intricate interactions among the feature values, we incorporate CNN as a foundational learner in the ensemble learning models. The incorporation of CNN not only helped with the predictive performance of the overall model but also offered more varied feature representations for the integrated model, hence improving its generalization capability.