K-means Clustering Lab
Find closest centroid
- Run this code for as many times as there are data points in X (notice how grabbing row variable from X.shape)
- With said data point in mind, one cluster at a time:
- calculate the delta between the point X and its centroid vectors, for however many dimensions as there are; sum them all
- appendix that delta to distance array
- Look at all the distances it gathered over each iteration, and returns the index of the smallest value (which relates to the centroid it was calculated via)
- Clear the distance array

Compute new centroid location
- For every cluster
- Gets all data points from the matrix X for said centroid (starting with 0)
- for said centroid, takes all the data that has been moved into the points matrix and takes the average, one axis at a time (hence axis =0)

Run the k-means algorithm

Can also randomly initialize the centroids:

Image compression with K means
- First two dimensions are location of pixel, then this pixel has separate R,G, and B values
- For example,
original_img[50, 33, 2] gives the blue intensity of the pixel at row 50 and column 33.
- Take all the pictures' RGB values - in 3-dimensional space - and then find optimal centroid clusters. Then replace those pixels with their associated centroid.


Anomaly Detection
Define the values and shape of each feature

