Highlights
K-means clustering is a clustering method. The algorithm can be described as follows:
0) Determine how many (k) clusters you will search for.
1) Randomly assign points in your data to each of the clusters.
2) Once all values have been assigned to a cluster, calculate the means or the centroid of the values in each cluster.
3) Reassign values to clusters by associating values in the data set to the nearest (Euclidean distance) centroid.
4) Repeat steps 2 and 3 until convergence. Convergence occurs when no values are reassigned to a new cluster.
Task 1
Write code to perform k-means clustering on the values in the matrix `dat`.
The true group labels are provided in the vector `true_groups`. Of course, you can't use that until the very end where you will perform some verification.
Requirements:
1) So everyone will get consistent results, I have performed the initial assignment of points to clusters.
2) With each iteration, plot the data, colored by their current groupings, and the updated means.
3) Convergence is reached when group assignments no longer change. Your k-means clustering algorithm should reach convergence fairly quickly.
4) Print out a 'confusion' matrix showing how well the k-means clustering algorithm grouped the data vs the 'true labels.'
Kernelized K-means Clustering
To perform Kernelized K-means clustering, we will use Kernel Functions. A Kernel transforms our 2D point into another point in a higher dimension and returns the inner (dot) product of pair of points in the higher dimension.
Task 2
Instead of random assignments, place all points into the same cluster, with the exception of the first value, which will be placed in the second cluster.
Using the coordinates of the data projected in 3 dimensions, calculate the (3-dimensional) centroids of each cluster.
Task 3
Measure the squared Euclidean distance from each of the 8 values to both centroids. Produce a matrix that records these distances. It will be an 8 x 2 matrix. The first column will be the distance from each point to the first centroid (center of the 7 points in cluster 1). The second column will be the distances from each point to the second centroid (this cluster has only the first coordinate in it).
Assign each point to the cluster whose centroid is nearer. Update your Z values accordingly.
Task 4
To reduce computational time, we will create a matrix of all the products resulting from applying the Kernel function to every pair of points. (We find $K(\mathbf{x}_m, \mathbf{x}_m)$ for all pairs of m, r). This is similar to creating a multiplication table, except we are using the Kernel function. The calculations in the future will use these Kernel function products, and rather than having to redo the calculation each time, we will simply look up the product in the table.
This Stats 102B: Statistics Assignment has been solved by our Statistics Experts at My Uni Paper. Our Assignment Writing Experts are efficient to provide a fresh solution to this question. We are serving more than 10000+ Students in Australia, UK & US by helping them to score HD in their academics. Our experts are well trained to follow all marking rubrics & referencing style.
Be it a used or new solution, the quality of the work submitted by our assignment experts remains unhampered. You may continue to expect the same or even better quality with the used and new assignment solution files respectively. There’s one thing to be noticed that you could choose one between the two and acquire an HD either way. You could choose a new assignment solution file to get yourself an exclusive, plagiarism (with free Turnitin file), expert quality assignment or order an old solution file that was considered worthy of the highest distinction.
© Copyright 2026 My Uni Papers – Student Hustle Made Hassle Free. All rights reserved.