<p dir="auto">Hello.</p>
<ol dir="auto">
<li>The function <code class="notranslate">silhouette_samples</code> of <code class="notranslate">sklearn.metrics.cluster</code>  there are such cod rows:</li>
</ol>
<div class="snippet-clipboard-content notranslate position-relative overflow-auto" data-snippet-clipboard-copy-content="results = zip(*pairwise_distances_chunked(X, reduce_func=reduce_func,
                                              **kwds))
intra_clust_dists, inter_clust_dists = results
intra_clust_dists = np.concatenate(intra_clust_dists)
inter_clust_dists = np.concatenate(inter_clust_dists)"><pre class="notranslate"><code class="notranslate">results = zip(*pairwise_distances_chunked(X, reduce_func=reduce_func,
                                              **kwds))
intra_clust_dists, inter_clust_dists = results
intra_clust_dists = np.concatenate(intra_clust_dists)
inter_clust_dists = np.concatenate(inter_clust_dists)
</code></pre></div>
<p dir="auto">I've checked the work of clustering algorithms with np.concatenation and without ones. and nothing happened. So what is the role of that concatenations?</p>
<ol start="2" dir="auto">
<li>In the beginning of function <code class="notranslate">silhouette_samples</code> you create an object of LabelEncoder.<br>
What is the reason to encode the labels after clustering algorithms, which return the labels in form of integer numbers from -1 to inf? As I tested on Iris dataset, the following function works well even with np.unique</li>
</ol>
<div class="snippet-clipboard-content notranslate position-relative overflow-auto" data-snippet-clipboard-copy-content=" le = LabelEncoder()
 labels = le.fit_transform(labels)
 n_samples = len(labels)
 label_freqs = np.bincount(labels)
# Alternative
#check_number_of_labels(len(np.unique(labels)), n_samples)
  check_number_of_labels(len(le.classes_), n_samples)"><pre class="notranslate"><code class="notranslate"> le = LabelEncoder()
 labels = le.fit_transform(labels)
 n_samples = len(labels)
 label_freqs = np.bincount(labels)
# Alternative
#check_number_of_labels(len(np.unique(labels)), n_samples)
  check_number_of_labels(len(le.classes_), n_samples)
</code></pre></div>
<p dir="auto">Thank you!</p>
<h4 dir="auto">Description</h4>
<p dir="auto">ValueError thrown when using dump_svmlight_file on a pandas dataframe that contains NaN values. The expected behavior should be to skip NaN values.</p>
<h4 dir="auto">Steps/Code to Reproduce</h4>
<p dir="auto">from sklearn.datasets import dump_svmlight_file<br>
import pandas as pd<br>
df=pd.read_csv('somefile.csv')<br>
dump_svmlight_file(df,[0]*len(df),'svmlightfile')</p>
<h4 dir="auto">Actual Results</h4>
<p dir="auto">Traceback (most recent call last):<br>
File "", line 1, in <br>
File "/usr/lib64/python3.3/site-packages/sklearn/datasets/svmlight_format.py", line 393, in dump_svmlight_file<br>
Xval = check_array(X, accept_sparse='csr')<br>
File "/usr/lib64/python3.3/site-packages/sklearn/utils/validation.py", line 398, in check_array<br>
_assert_all_finite(array)<br>
File "/usr/lib64/python3.3/site-packages/sklearn/utils/validation.py", line 54, in _assert_all_finite<br>
" or a value too large for %r." % X.dtype)<br>
ValueError: Input contains NaN, infinity or a value too large for dtype('float64').#### Expected Results</p>

<h4 dir="auto">Versions</h4>
<p dir="auto">Linux-2.6.32-573.26.1.el6.centos.plus.x86_64-x86_64-with-centos-6.7-Final<br>
Python 3.3.0 (default, Feb 12 2013, 17:01:04)<br>
[GCC 4.4.6 20120305 (Red Hat 4.4.6-4)]<br>
NumPy 1.9.2<br>
SciPy 0.14.1<br>
Scikit-Learn 0.17.1</p>