Commits

Dhananjay Nene  committed 04b4e70

Randomised centroids for k-means exercise

  • Participants
  • Parent commits 041998f

Comments (0)

Files changed (1)

File exercise-7/octave/kMeansInitCentroids.m

 %               the dataset X
 %
 
-
+% Initialize the centroids to be random examples
+% Randomly reorder the indices of examples
+randidx = randperm(size(X, 1));
+% Take the first K examples as centroids
+centroids = X(randidx(1:K), :);