title: K-means with cosine distance
body: <p>I have to write program that cluster using k-means. I have TF-IDF and also cosine similarity that looks like that</p>
  
  <pre><code>1.00    0.17    0.46    0.40    0.89
  0.17    1.00    0.83    0.60    0.58
  0.46    0.83    1.00    0.30    0.67
  0.40    0.60    0.30    1.00    0.73
  0.89    0.58    0.67    0.73    1.00
  </code></pre>
  
  <p>I have the output for 2-means, it goes into two group with the first centroids: D1 and D2 because their similarity is lowest( 0.17 ) so the groups are {D1, D5} and {D2, D3, D4} but what if I had to choose 3-means? How do I then choose my start centroids? </p>
  
  <p>And another thing I do not understand, I am taking my TF-IDFS that I have as follows:</p>
  
  <pre><code>0.2 0.4 0.8 0.0 0.2
  0.0 0.4 0.2 0.8 0.2
  0.8 0.0 0.2 0.4 0.4
  </code></pre>
  
  <p>and make new centroids for my groups</p>
  
  <p>Group1:  T1- 0.2  T2- 0.1  T3- 0.6
  Group2:  T1- 0.4  T2- 0.4(6) T3-0.2</p>
  
  <p>And now what do I do to again assign my documents to new centroids? Do I have to calculate now the cosine between my centroids and documents? And whether the cos value is higher to group centroid I put it there?</p>