title: a kind of kmean clustering
body: <p>I tried to run this code in python2.7 with a matrix 20*20 and i want to get two cluster just like the kmean algorithm. </p>
  
  <p><strong>js</strong></p>
  
  <p><div class="snippet" data-lang="js" data-hide="false">
  <div class="snippet-code">
  <pre class="snippet-code-js lang-js prettyprint-override"><code>import numpy as np
  
  filename = np.genfromtxt('Matrix.txt')
  M = np.sort (np.random.choice (2,20)) 
  
  ##m = np.copy(M) =&gt; I get an error there : 'module' object is not callable
  M= m  #this option work better but i am not sure that it is appropriate
  
  #initialization of the clusters
  C = {}
  
  for t in xrange(tmax=100):
   #determination of clusters
   J = np.mean(filename[:,M], axis = 1)
   for k in range (2):
    C[k] = np.where (J==k, 0,0) # np.where (J==k)=&gt; another error for 'np.where': it take exactly three arguments but one given.I saw that it could take only one argument
  
   #update  
   for k in range (2):
    J = np.mean(filename[np.ix_(C[k],C[k])], axis = 1)
    j= np.argmin(J)
    m[k] = C[k][j] #[j]  =&gt; another error for '[j]': invalid index to scalar variable
  
      #results
  print M, C
  
   </code></pre>
  </div>
  </div>
  </p>
  
  <p><strong>my result</strong></p>
  
  <blockquote>
    <p>{0 : 0, 1:0}</p>
  </blockquote>
  
  <p><strong>the expected result</strong></p>
  
  <blockquote>
    <p>{0:8, 1:12}</p>
  </blockquote>
  
  <p>in example meaning that there is 8 elements in cluster '0' and 12 in cluster '1'.
  This is probably because of 'np.where ' function but i am not sure.</p>
  
  <p>I run the program without all the errors that i previously mentioned for get this result but it doesn't work as well it should</p>
  
  <p>Thanks for your help</p>