K-means & Nearest Neighbour Clustering
K-means & Nearest Neighbour Clustering
The choice of distance metric greatly influences the output of clustering algorithms like K-means or Nearest Neighbour, as it determines how distances between points are computed. Both algorithms use Euclidean distance, which calculates straight-line distances, impacting cluster formation. For K-means, this means points are grouped based on their proximity to centroids determined by Euclidean calculations . Similarly, Nearest Neighbour uses this metric to compare distances between points and add them to clusters only if the distance is within a specified threshold . A change in metric, like using Manhattan or cosine, would lead to different cluster shapes and possibly different cluster compositions.
The main differences between the clustering outcomes of the K-means algorithm and the Nearest Neighbour algorithm for points A1 through A8 are in how the clusters are formed and the final cluster compositions. In the K-means algorithm, the initial clusters are determined by the seed points, and after three epochs, the final clusters are: Cluster 1: {A1, A4, A8}, Cluster 2: {A3, A5, A6}, Cluster 3: {A2, A7} with respective centers C1=(3.66, 9), C2=(7, 4.33), and C3=(1.5, 3.5). The Nearest Neighbour algorithm forms clusters by sequentially evaluating the distance to the threshold and placing closest points together. The final clusters in this method are: Cluster 1: {A1, A4, A8}, Cluster 2: {A2, A7}, Cluster 3: {A3, A5, A6} . Despite different initial steps, the clusters converge to similar groupings indicating robustness across methods.
The final cluster compositions for both K-means and Nearest Neighbour algorithms show remarkable similarities despite differing methodologies. For both, the clusters formed are: Cluster 1: {A1, A4, A8}, Cluster 2: {A3, A5, A6}, and Cluster 3: {A2, A7}. These outcomes reveal that while Nearest Neighbour bases groupings on direct pairwise distance consideration relative to a threshold, K-means iteratively clusters based on distance to computed centroids . This indicates that the intrinsic spatial distribution of points in this dataset supports similar logical groupings given Euclidean distances, highlighting how different algorithms can align when data naturally cluster in certain ways.
Setting the threshold value to T=4 in Nearest Neighbour clustering determines how close points must be to form clusters. With this specific threshold, a point joins a cluster if its distance to at least one member is less than 4. This results in Cluster 1 including close points A1, A4, and A8; Cluster 2 containing A2 and A7, and Cluster 3 composed of A3, A5, and A6, reflecting how proximity and threshold compare favorably for clustering . A different threshold could lead to different assignments by either merging clusters or making them smaller depending on whether the threshold is increased or decreased.
The computational complexity of the K-means algorithm is primarily driven by the distance calculations and centroid recomputation in each iteration. The time complexity is O(n * k * i * d), where n is the number of data points (8 for the dataset A1 through A8), k is the number of clusters (3 in this case), i is the number of iterations until convergence (3 epochs in the provided solution), and d is the number of dimensions of the data points (2 since each point is a coordinate pair). Each iteration involves calculating the distance from each point to each centroid and possibly updating cluster membership, followed by recalculating centroids which involves computing the mean for each cluster. These calculations sum up over multiple iterations, contributing to the algorithm's computational burden .
In the Nearest Neighbour algorithm, the threshold value determines the maximum allowed distance for a point to be included in the same cluster as another point. For the dataset with points A1 through A8, a threshold value of 4 means that a point will only be clustered with another point if its Euclidean distance is less than or equal to 4. This threshold results in the formation of clusters with proximity-based members, leading to the final clusters being: Cluster 1: {A1, A4, A8}, Cluster 2: {A2, A7}, and Cluster 3: {A3, A5, A6} . A higher or lower threshold could change these groupings significantly.
Several factors can influence the number of epochs to convergence in K-means. The initial seed choice, spatial distribution of the data, and tolerance for movement all play roles. For A1 through A8, fewer epochs might occur if seeds start closer to natural centers, minimizing required movement. More epochs could result if initial seeds are poorly placed, requiring iterative adjustments to find natural groupings. Less variance within core point groups or high movement tolerance for centroid positionings could allow quicker stabilizations compared to highly dispersed or complex distributions all potentially lead to variable convergence pacing .
The K-means algorithm determines the number of iterations needed to achieve convergence by monitoring changes in cluster assignments and centroids. Convergence is reached when the cluster assignments do not change between iterations. In the given example, after three epochs, the clusters stabilize with no further changes in assignment or centroid positions, demonstrating convergence. The clusters after each epoch are adjusted based on recalculated centers until no significant changes occur .
In K-means clustering, centroid recalculation involves computing the mean of all points belonging to each cluster, which then becomes the new center for that cluster. For dataset points A1 through A8, after each epoch, centroids were recalculated leading to updated cluster arrangements. Initially, clusters are based on distances from initial seeds A1, A4, and A7. After recalculation, new centroids: C1=(3, 9.5), C2=(6.5, 5.25), C3=(1.5, 3.5) were formed after the second epoch stabilizing to C1=(3.66, 9), C2=(7, 4.33), C3=(1.5, 3.5) in the third, stabilizing clustering with no more reallocations of points indicated by lack of changes from previous epoch upon recomputation . This demonstrates the iterative refinement until convergence.
In the K-means algorithm, choosing initial seed points can significantly affect the clustering outcome. Strategies for selecting initial seeds include random selection, k-means++ which chooses seeds to be far apart, or using domain knowledge for informed decision. In the given problem, the seeds are initially A1, A4, and A7 . This choice determines the initial grouping but can lead to different clusters if reset differently after each epoch. In this case, after three epochs with the given initialization, the final clusters become stable with: Cluster 1: {A1, A4, A8}, Cluster 2: {A3, A5, A6}, and Cluster 3: {A2, A7} . The choice of initial seeds influences which points will initially congregate, impacting the number of iterations required for convergence.