5.4 Some unsupervised learning on training data to initially cluster data

Any way you want… k-nearest neighbors is often a good choice. It’s up to you to determine how your data best make sense to group together.

library(caret)
knnFit=knn3(x=training[,-1], # training set
            y=training[,1], # training set class labels
            k=5)
# predictions on the test set (which is also the training set in this case)
trainPred=predict(knnFit,training[,-1])