title: Python: validation k-means clustering
body: <p>I want to compare two different clusters computed with k-means library of <code>sklearn</code>.</p>
  
  <pre><code>from sklearn.cluster import KMeans
  
  ya = KMeans(n_clusters=3).fit_predict(Xa)
  yb = KMeans(n_clusters=3).fit_predict(Xb)
  </code></pre>
  
  <p>Where </p>
  
  <pre><code>ya
  array([0, 2, 1, 1, 2, 2, 0, 2, 2, 1, 0, 0, 1, 2, 0, 1, 0, 0, 0, 0, 2, 2, 2,
         2, 2, 0, 2, 0, 2, 0, 2, 2, 2, 0, 0, 1, 0, 2, 2, 2, 2, 2, 2, 0, 0, 2,
         2, 0, 1, 0, 2, 2, 2], dtype=int32)
  </code></pre>
  
  <p>and </p>
  
  <pre><code>yb
  array([1, 2, 0, 0, 2, 2, 1, 2, 2, 0, 1, 1, 0, 2, 1, 0, 1, 1, 1, 1, 2, 2, 2,
         2, 2, 1, 2, 1, 2, 1, 2, 2, 2, 1, 1, 0, 1, 2, 2, 2, 2, 2, 2, 1, 1, 2,
         2, 1, 0, 1, 2, 2, 2], dtype=int32)
  </code></pre>
  
  <p>The clusters are the same but the labels are different. In order to compute the difference I was doing:</p>
  
  <pre><code>sm = difflib.SequenceMatcher(None,list(ya),list(yb))
  sm.ratio()
  </code></pre>
  
  <p>But of course it does not work because of the labels. Is there any way to compare two clusters?</p>