title: Which SciPy sparse matrix class is best to compute a distance matrix?
body: <p>I have a relatively large NumPy array (nearly 300k rows and 20+ columns, though most values are 0) for which I need to compute a distance matrix using scikit-learn's <a href="http://scikit-learn.org/stable/modules/generated/sklearn.metrics.pairwise.pairwise_distances.html" rel="nofollow noreferrer">pairwise_distances</a> function.</p>
  
  <p>Unfortunately, this process runs into a memory error unless I convert the input array to a sparse matrix. SciPy offers many <a href="http://docs.scipy.org/doc/scipy/reference/sparse.html" rel="nofollow noreferrer">sparse matrix classes</a> and I do not know which one is best for this particular situation.</p>
  
  <p>I found an <a href="https://stackoverflow.com/questions/15755270/scipy-sparse-matrices-purpose-and-usage-of-different-implementations">SO answer</a> that favors CSR or CSC, but I am unclear which one would be best to compute a distance matrix. Any suggestions are welcome!</p>