## 4 Wavelet Based Unsupervised Learning Algorithm
### Clustering Algorithm and Graph Generation  
With these vectors in \(\mathbb{R}^{8}\), a distance or measure of similarity was calculated between two different days' worth of blood glucose data by computing the Euclidean norm between the vectors associated with each day. But in order to first compare two patients, we had to ensure that the samples were as representative as possible of an \"ordinary\" day for the patient under investigation. Due to the inherent unpredictability of diabetes, there are almost assuredly going to be a few days for each patient that are not representative of the patient's typical blood glucose behavior. To find these \"outlying\" days, we applied the Laplacian Eigenmap Method of [PERSON] using a slight modification of the Euclidean norm, known as the heat kernel (The parameter value we used in the heat kernel was \(t=0.5\).) (see [8] and Appendix) to assign a similarity measure between two days of a patient. The resulting 2-dimensional graph typically contained one main cluster with several days isolated away from the main cluster. A total of 25% of the days were then removed by computing the centroid of the plotted points in \(\mathbb{R}^{2}\), removing the point farthest from the centroid, recomputing the centroid, and repeating until 25% of the points were removed. Subsequently, only these non-outlying days were considered. We chose 25% to ensure that the outlying days were removed while still leaving enough days within the central cluster to properly compare to other diabetics. Refining this process of selecting a subset of the CGM data to appropriately represent a patient is a possibility for future research. With each patient being represented by a set of 8-dimensional vectors associated with these non-outlying days, two different patients were compared by using the Hausdorff metric. Hausdorff distances were then used to calculate the four patients nearest to a particular patient (one of these will always be the particular patient himself), and this information was used as input in the Laplacian Eigenmap Method using the nearest neighbor strategy developed in [8]. This yielded Figure 5, which is a 2-dimensional embedding of the 8-dimensional vectors into the unit square and is similar to other clustering graphs found in [8] and elsewhere in the literature. Examination of the statistics vectors revealed significant variation primarily in three statistics: skewness of the coefficient magnitudes, kurtosis of the coefficient magnitudes, and skewness of the error of the linear predictors. Thus, these were the factors that most strongly influenced the clustering. Additionally, all three statistics were related in the sense that if one was high for a patient, the other two were also likely to be high. (High values were as follows: skewness of theor higher), kurtosis of the coefficient magnitudes (65 or higher), and skewness of the error of the linear predictors (\(-0.05\) or higher).) From this information, we devised a coloring scheme that indicated the average level of these statistics. They were colored green, red, and blue for high, medium, and low values respectively. Coloring Figure 5 with this scheme led to Figure 3.  
Figure 5 can also be independently colored based on the PLA index with green, red, and blue representing low, medium, and high PLA indices respectively. This coloring led to Figure 4. As previously described, Figures 3 and 4 are similar in their banded appearance. It is important to note that high values of the three statistics correspond to most of the wavelet detail coefficients being small, which means less variability in the CGM data, and hence a small PLA index. Therefore, the relatively simple PLA index potentially incorporates the entire sophisticated analysis relying on wavelets into a single value. Computationally, this method is highly dependent on the number of diabetic patients being compared and the number of day's worth of complete data for each patient.