K Means Clustering
K means Clustering is one of the simplest and most commonly used unsupervised clustering algorithms around. The general approach is as follows: Choose k centroids randomly. Calculate the distance from each point in the dataset to be classified to each centroid. Assign each point to the nearest centroid. Calculate the centroids of the resulting clusters. Repeat until the centroids don't move too much. Here is some R code which generates a data set and implements the algorithm. Click here to see the animation. ########################################### # R code to implement k means classification ########################################## # NB - to make the animation - make sure you have ImageMajick installed from http://www.imagemagick.org/ ########################################## # initiate libraries library ( animation ) # set working directory setwd ( 'C:/Users/RF186004/Desktop' ) ######################################### ...