# Adaptive Stacking Ensemble Techniques for Early Severity Classification of COVID-19 Patients
## 3 Proposed Method
### Preprocessing

Table 1: _Cont._values as _No_ and _0 weeks_ for _PREG_ and _PREGW_, respectively. We used the KNN imputation method for the remaining missing values that exceeded the proportion of 10%. In KNN, the value of \(k\), which represents the number of neighbors, significantly affects the imputation results. A small \(k\) value can make the model sensitive to noise, whereas a large \(k\) value can smooth the decision boundary, leading to the loss of important patterns in the data. To select the optimal \(k\) value, we used a scoring metric based on Jensen-Shannon divergence. This metric evaluates the quality of the imputed values by comparing them with the original distribution. Consequently, we selected \(k=2\), which yielded the smallest divergence. Figure 2 shows the imputed distribution of the KNN for the blood results, including _HCT_, _LYMPHO_, _PLT_, and _WBC_. Algorithm 1 describes the procedure for imputing missing values. ```
1:for each missing value in \(x\)do:
2:if missing values < 10%
3:if\(x\) is categorical type data:
4:input the missing value with the most frequent value
5:elseif\(x\) is numeric type data:
6:input the missing value with the median value
7:elseifmissing values > 10%
8:if\(x\) is related to PREG:
9:if\(SEX\) is male
10:inputePREG as 'No' and _PREGW_ as '0 weeks'
11:elseif\(SEX\) is female:
12:ifPREG records are empty
13:inputePREG as 'No' and _PREGW_ as '0 weeks'
14:ifPREG is recorded as 'No'
15:inputePREG as '0 weeks'
16:endfor
17:initialize\(score\) as an empty list
18:for each number of neighbor set \(n\)do:
19:inpute the remaining values using KNN approach
20:\(score\leftarrow\) calculate divergence score for comparison with original distribution
21:endfor
22:\(k\leftarrow\) index corresponding to _min(score)_
23:return imputed missing values using the selected \(k\) value
```  
**Algorithm 1** Missing Value Imputation  
Figure 2: Imputed distribution of KNN for blood test results. The scoring metric based on the Jensen-Shannon divergence, which is used for comparison with the original distribution, can be calculated as follows:  
\[ \begin{split} Score&=\sqrt{\frac{1}{2}(KL(p,\ m)+KL(q,m) \ \ where\\ KL(p,\ m)&=\sum\limits_{x\in\Omega}p(x)\text{log} \Big{(}\frac{p(x)}{q(x)}\Big{)},\ m=0.5*(p+q)\end{split}  \tag{1}\]  
where \(p\) denotes the original data distribution and \(q\) denotes the imputed data distribution from the KNN approach; \(m\) denotes the mixed distribution of \(p\) and \(q\). This score measures the average divergence between the two distributions relative to the mixed distribution. A score of 0 indicates identical distributions, whereas a score of 1 indicates maximally different distributions. We then performed standardization and mean encoding of the datasets. Standardization involves rescaling the distribution of values such that the mean of the observed values is 0 and the standard deviation is one. Thus, we ensured that all features, except \(\mathit{CSS}\), followed a Gaussian normal distribution with a mean of 0 and standard deviation of 1. This procedure is calculated as follows:  
\[Data_{\mathit{standard}}=\frac{Data-\mu(Data)}{\sigma(Data)} \tag{2}\]  
where \(\mu\)(train) and \(\sigma\)(train) represent the mean and standard deviation for each feature in the dataset, respectively. Following standardization, we performed a mean encoding of the categorical values. This procedure transforms the categorical values into the mean of the target variables for each category.