title: How to use sparse matrix in python hcluster?
body: <p>I'm trying to use hcluster library in python. I have no enough python knowledges to use sparse matrix in hcluster. Please help me anybody. So, that what I'm doing: </p>
  
  <pre><code>import os.path
  import numpy
  import scipy
  import scipy.io 
  from hcluster import squareform, pdist, linkage, complete 
  from hcluster.hierarchy import linkage, from_mlab_linkage 
  from numpy import savetxt 
  from StringIO import StringIO 
  </code></pre>
  
  <p>data.dmp contains matrix looks like:</p>
  
  <pre><code>  A B C D
  A 0 1 0 1 
  B 1 0 0 1 
  C 0 0 0 0 
  D 1 1 0 0 
  </code></pre>
  
  <p>and contains only upper-right part of matrix. I don't know how to spell it in english correctly :) so, all numbers upper than main diagonal
  so data.dmp contains :    1 0 1, 0 1 , 0 </p>
  
  <pre><code>f = file('data.dmp','r')  
  s = StringIO(f.readline()).getvalue()
  f.close()
  
  matrix = numpy.asarray(eval("["+s+"]"))
  </code></pre>
  
  <p>by unknown reason for me, hcluster uses inverted values,  for example I use 0 if A!=C,and use 1 if A == D</p>
  
  <pre><code>sqfrm = squareform(matrix)
  Y = pdist(sqfrm, metric="cosine")
  </code></pre>
  
  <p>linkage Y</p>
  
  <pre><code>Z = linkage(Y, method="complete")
  </code></pre>
  
  <p>So, matrix Z is what I need (if I correctly used hcluster?)</p>
  
  <p>But I have next problems:</p>
  
  <ol>
  <li><p>I want to use sparse matrix for
  the huge amount of input data, cause it's time
  consuming to generate input data
  like now, I need to import data to
  python from another language, thats
  why I need read text file. Please
  kindly, python guru's suggest how to
  make it?</p></li>
  <li><p>To people that used python
  hcluster, I need to process huge
  amount of data, hundreds of rows,
  it's possible to do in hcluster?
  This algorithm realy produce correct
  HAC?</p></li>
  </ol>
  
  <p>Thank you for reading, I appreciate any help! </p>