<p dir="auto">There seems to be a bug in the documentation of the classification of text documents: <a href="http://scikit-learn.org/stable/auto_examples/text/mlcomp_sparse_document_classification.html#sphx-glr-auto-examples-text-mlcomp-sparse-document-classification-py" rel="nofollow">http://scikit-learn.org/stable/auto_examples/text/mlcomp_sparse_document_classification.html#sphx-glr-auto-examples-text-mlcomp-sparse-document-classification-py</a></p>
<p dir="auto">The files are opened as utf-8 which leads to a bug. I have solved the issue changing "open(f)" into "open(f, encoding='latin1')".</p>
<p dir="auto">Sometimes I get what seems to be a divide-by-zero in the Nyström kernel approximation:</p>
<div class="snippet-clipboard-content notranslate position-relative overflow-auto" data-snippet-clipboard-copy-content="/usr/local/lib/python2.7/site-packages/sklearn/kernel_approximation.py:445: RuntimeWarning: divide by zero encountered in divide
  self.normalization_ = np.dot(U * 1. / np.sqrt(S), V)
/usr/local/lib/python2.7/site-packages/sklearn/kernel_approximation.py:445: RuntimeWarning: invalid value encountered in divide
  self.normalization_ = np.dot(U * 1. / np.sqrt(S), V)"><pre class="notranslate"><code class="notranslate">/usr/local/lib/python2.7/site-packages/sklearn/kernel_approximation.py:445: RuntimeWarning: divide by zero encountered in divide
  self.normalization_ = np.dot(U * 1. / np.sqrt(S), V)
/usr/local/lib/python2.7/site-packages/sklearn/kernel_approximation.py:445: RuntimeWarning: invalid value encountered in divide
  self.normalization_ = np.dot(U * 1. / np.sqrt(S), V)
</code></pre></div>
<p dir="auto">I am trying to minimal example to reproduce the problem, but so far I have not been able to do so. I expect that some eigenvalues of the kernel matrix are rounded to zero, which could be caused by a rank-deficient kernel matrix. This is with sklearn version 0.13.1.</p>
<p dir="auto">If that is the case, this problem can be fixed by adding a tiny ridge to the kernel matrix, or by adding a tiny value to the eigenvalues <code class="notranslate">S</code>. Alternatively, one could use only positive eigenvalues in the computation.</p>