title: NaN/inf values in scikit-learn manifold learning functions
body: <p>I have a manifold learning / non-linear dimensionality reduction problem where I know distances between objects up to some threshold, and beyond that I just know that the distance is "far". Also, in some cases some of the distances might be missing. I am trying to use <code>sklearn.manifold</code> in order to perform the task of finding a 1d representation. A natural representation would be to represent "far" distances an <code>inf</code> and missing distances as <code>nan</code>.</p>
  
  <p>However, it seems that currently <code>scikit-learn</code> does not support <code>nan</code> and <code>inf</code> values in distance matrices given to manifold learning functions in <code>sklearn.manifold</code>, since I get <code>ValueError: Array contains NaN or infinity</code>.</p>
  
  <p>Is there a conceptual reason for this? Some methods seem to be especially suitable for <code>inf</code>, e.g. non-metric MDS. Also I know that some implementations of these methods in other languages are able to handle missing/inf values.</p>
  
  <p>Instead of using <code>inf</code> I have considered setting "far" values to a very large number, but I am not sure how this will affect the results.</p>
  
  <p><strong>Update:</strong></p>
  
  <p>I dug in the code of <code>sklearn.manifold.MDS._smacof_single()</code> and found a piece of code and a comment saying that <code>"similarities with 0 are considered as missing values"</code>. Is this an undocumented way to specify missing-values? Does this work with all manifold functions?</p>