# Non-Invasive and Accurate Blood Glucose Detection Based on an Equivalent Bioimpedance Spectrum
## 6 Classification of Blood Glucose Parameters Based on the K-Proximity Method
### Hyperglycemia Recognition Using the K-Nearest Neighbor Algorithm  
Based on impedance spectra of hyperglycemia samples, the K-nearest neighbor algorithm [27; 28] is used to recognize type 2 diabetes mellitus. Considering the small sample size of the electrical impedance spectrum, the KNN algorithm performs effectively in processing small-scale datasets with limited features. Notably, it does not require model retraining when new samples are added; instead, it simply incorporates these samples into the training set. This characteristic aligns well with the real-time requirements of blood glucose prediction scenarios. In contrast, other algorithms, such as CNN and SVM, are more susceptible to overfitting when handling small-scale data, with CNN being primarily suited for image processing. Meanwhile, SVM demonstrates significant advantages in processing high-dimensional data. The training set \(T\) is a \(d\)-dimensional feature space containing two categories, namely \"hyperglycemia samples\" and \"standard blood glucose samples\", and it is denoted as \(T=\left\{\ x_{i}\in R^{d}\right\}_{i=1}^{N}\). The corresponding sample label of the training set is \(\left\{y_{1},y_{2},\cdots,y_{N}\right\}\), in which \(y_{i}\in\left\{0,1\right\}.\) Label \(\left\{0\right\}\) and \(\left\{1\right\}\) stand for hyperglycemia and standard blood glucose samples, respectively. Furthermore, \(x_{i}\) is a sample to be tested. The characteristics of the K-nearest neighbor algorithm are \(\alpha=[\alpha_{1},\alpha_{2},\alpha_{3},\alpha_{4}]\). Here, \(\alpha_{1}\) and \(\alpha_{2}\) indicate the spectrum features at 25-35 MHz and 40-60 MHz, respectively; \(\alpha_{3}=1\) means the person under test is male, and \(\alpha_{3}=0\) means female; \(\alpha_{4}\) is the body surface temperature of the tested person. The process of determining parameter \(\alpha_{1}\) is as follows:  
1. Find out the maximum and minimum in the frequency range of 25-35 MHz, denoted as \(Z_{(25-35)-\max-1}\) and \(Z_{(25-35)-\min-1}\), respectively. 2. Find out the frequency values corresponding to the maximum and minimum, denoted as \(f_{(25-35)-\max-1}\) and \(f_{(25-35)-\min-1}\), respectively. 3. Let \(\alpha_{1}{=}f_{(25-35)-\max-1}-f_{(25-35)-\min-1}\). The parameter \(\alpha_{2}\) is calculated in a similar way among 40-60 MHz, i.e., \(\alpha_{2}{=}f_{(40-60)-\max-1}-f_{(40-60)-\min-1}\). The Euclidean distance is calculated using the K-nearest neighbor algorithm. Furthermore, k is set to 5 for classification of the sample size and classification effect, and the results are shown in Figure 10.  
In the experiment, it is found that the near-threshold samples have \"high blood glucose characteristics\" but may be identified as \"standard blood glucose\". The reason is  
Figure 10: Euclidean distance KNN for the sample to be tested for standard blood glucose. that such samples have \"declining\" trends in 25-30 MHz, which is in line with the judgment standard of a \"hyperglycemic sample\". But, in group recognition, the Euclidean distance only involves the absolute distance between sample points, which makes it impossible to judge the trend of the impedance spectrum. To solve this problem, the Manhattan distance is used along with the Euclidean distance to identify \"hyperglycemic samples\". The identification process is shown in Figure 11.  
The classification result is defined as follows: in the K-nearest neighbor algorithm using the Euclidean distance, \(x_{1}=0\) indicates a \"hyperglycemic sample\", otherwise \(x_{1}=1\); in the K-nearest neighbor using the Manhattan distance, \(x_{2}=0\) indicates a \"hyperglycemic sample\", otherwise \(x_{2}=1\); if both algorithms classify the test sample as a \"hyperglycemic sample\", the output will be a \"hyperglycemic sample\". The proposed classification algorithm is evaluated by the classification accuracy rate or classification accuracy. Let \(n_{Actest}\) be the number of samples correctly classified in the test set and \(n_{test}\) be the number of all samples in the test set.