<div class="snippet-clipboard-content notranslate position-relative overflow-auto" data-snippet-clipboard-copy-content="Darwin-15.0.0-x86_64-i386-64bit
('Python', '2.7.11 |Anaconda custom (x86_64)| (default, Dec  6 2015, 18:57:58) \n[GCC 4.2.1 (Apple Inc. build 5577)]')
('NumPy', '1.11.0')
('SciPy', '0.17.0')
('Scikit-Learn', '0.17.1')"><pre class="notranslate"><code class="notranslate">Darwin-15.0.0-x86_64-i386-64bit
('Python', '2.7.11 |Anaconda custom (x86_64)| (default, Dec  6 2015, 18:57:58) \n[GCC 4.2.1 (Apple Inc. build 5577)]')
('NumPy', '1.11.0')
('SciPy', '0.17.0')
('Scikit-Learn', '0.17.1')
</code></pre></div>
<p dir="auto">When trying to run a t-SNE</p>
<div class="snippet-clipboard-content notranslate position-relative overflow-auto" data-snippet-clipboard-copy-content="proj = TSNE().fit_transform(X)
ValueError: array must not contain infs or NaNs"><pre class="notranslate"><code class="notranslate">proj = TSNE().fit_transform(X)
ValueError: array must not contain infs or NaNs
</code></pre></div>
<p dir="auto">However</p>
<div class="snippet-clipboard-content notranslate position-relative overflow-auto" data-snippet-clipboard-copy-content="np.isfinite(X).all() # True 
np.isnan(X).all() # False
np.isinf(X).all() # False"><pre class="notranslate"><code class="notranslate">np.isfinite(X).all() # True 
np.isnan(X).all() # False
np.isinf(X).all() # False
</code></pre></div>
<p dir="auto">Full Stack Trace:</p>
<div class="snippet-clipboard-content notranslate position-relative overflow-auto" data-snippet-clipboard-copy-content="
ValueError                                Traceback (most recent call last)
&lt;ipython-input-16-c25f35fd042c&gt; in &lt;module&gt;()
----&gt; 1 plot(X, y)

&lt;ipython-input-1-72bdb7124d13&gt; in plot(X, y)
     74 
     75 def plot(X, y):
---&gt; 76     proj = TSNE().fit_transform(X)
     77     scatter(proj, y)

/Users/joelkuiper/anaconda/lib/python2.7/site-packages/sklearn/manifold/t_sne.pyc in fit_transform(self, X, y)
    864             Embedding of the training data in low-dimensional space.
    865         &quot;&quot;&quot;
--&gt; 866         embedding = self._fit(X)
    867         self.embedding_ = embedding
    868         return self.embedding_

/Users/joelkuiper/anaconda/lib/python2.7/site-packages/sklearn/manifold/t_sne.pyc in _fit(self, X, skip_num_points)
    775                           X_embedded=X_embedded,
    776                           neighbors=neighbors_nn,
--&gt; 777                           skip_num_points=skip_num_points)
    778 
    779     def _tsne(self, P, degrees_of_freedom, n_samples, random_state,

/Users/joelkuiper/anaconda/lib/python2.7/site-packages/sklearn/manifold/t_sne.pyc in _tsne(self, P, degrees_of_freedom, n_samples, random_state, X_embedded, neighbors, skip_num_points)
    830         opt_args['momentum'] = 0.8
    831         opt_args['it'] = it + 1
--&gt; 832         params, error, it = _gradient_descent(obj_func, params, **opt_args)
    833         if self.verbose:
    834             print(&quot;[t-SNE] Error after %d iterations with early &quot;

/Users/joelkuiper/anaconda/lib/python2.7/site-packages/sklearn/manifold/t_sne.pyc in _gradient_descent(objective, p0, it, n_iter, objective_error, n_iter_check, n_iter_without_progress, momentum, learning_rate, min_gain, min_grad_norm, min_error_diff, verbose, args, kwargs)
    385     for i in range(it, n_iter):
    386         new_error, grad = objective(p, *args, **kwargs)
--&gt; 387         grad_norm = linalg.norm(grad)
    388 
    389         inc = update * grad &gt;= 0.0

/Users/joelkuiper/anaconda/lib/python2.7/site-packages/scipy/linalg/misc.pyc in norm(a, ord, axis, keepdims)
    127     &quot;&quot;&quot;
    128     # Differs from numpy only in non-finite handling and the use of blas.
--&gt; 129     a = np.asarray_chkfinite(a)
    130 
    131     # Only use optimized norms if axis and keepdims are not specified.

/Users/joelkuiper/anaconda/lib/python2.7/site-packages/numpy/lib/function_base.pyc in asarray_chkfinite(a, dtype, order)
   1020     if a.dtype.char in typecodes['AllFloat'] and not np.isfinite(a).all():
   1021         raise ValueError(
-&gt; 1022             &quot;array must not contain infs or NaNs&quot;)
   1023     return a
   1024 

ValueError: array must not contain infs or NaNs"><pre class="notranslate"><code class="notranslate">
ValueError                                Traceback (most recent call last)
&lt;ipython-input-16-c25f35fd042c&gt; in &lt;module&gt;()
----&gt; 1 plot(X, y)

&lt;ipython-input-1-72bdb7124d13&gt; in plot(X, y)
     74 
     75 def plot(X, y):
---&gt; 76     proj = TSNE().fit_transform(X)
     77     scatter(proj, y)

/Users/joelkuiper/anaconda/lib/python2.7/site-packages/sklearn/manifold/t_sne.pyc in fit_transform(self, X, y)
    864             Embedding of the training data in low-dimensional space.
    865         """
--&gt; 866         embedding = self._fit(X)
    867         self.embedding_ = embedding
    868         return self.embedding_

/Users/joelkuiper/anaconda/lib/python2.7/site-packages/sklearn/manifold/t_sne.pyc in _fit(self, X, skip_num_points)
    775                           X_embedded=X_embedded,
    776                           neighbors=neighbors_nn,
--&gt; 777                           skip_num_points=skip_num_points)
    778 
    779     def _tsne(self, P, degrees_of_freedom, n_samples, random_state,

/Users/joelkuiper/anaconda/lib/python2.7/site-packages/sklearn/manifold/t_sne.pyc in _tsne(self, P, degrees_of_freedom, n_samples, random_state, X_embedded, neighbors, skip_num_points)
    830         opt_args['momentum'] = 0.8
    831         opt_args['it'] = it + 1
--&gt; 832         params, error, it = _gradient_descent(obj_func, params, **opt_args)
    833         if self.verbose:
    834             print("[t-SNE] Error after %d iterations with early "

/Users/joelkuiper/anaconda/lib/python2.7/site-packages/sklearn/manifold/t_sne.pyc in _gradient_descent(objective, p0, it, n_iter, objective_error, n_iter_check, n_iter_without_progress, momentum, learning_rate, min_gain, min_grad_norm, min_error_diff, verbose, args, kwargs)
    385     for i in range(it, n_iter):
    386         new_error, grad = objective(p, *args, **kwargs)
--&gt; 387         grad_norm = linalg.norm(grad)
    388 
    389         inc = update * grad &gt;= 0.0

/Users/joelkuiper/anaconda/lib/python2.7/site-packages/scipy/linalg/misc.pyc in norm(a, ord, axis, keepdims)
    127     """
    128     # Differs from numpy only in non-finite handling and the use of blas.
--&gt; 129     a = np.asarray_chkfinite(a)
    130 
    131     # Only use optimized norms if axis and keepdims are not specified.

/Users/joelkuiper/anaconda/lib/python2.7/site-packages/numpy/lib/function_base.pyc in asarray_chkfinite(a, dtype, order)
   1020     if a.dtype.char in typecodes['AllFloat'] and not np.isfinite(a).all():
   1021         raise ValueError(
-&gt; 1022             "array must not contain infs or NaNs")
   1023     return a
   1024 

ValueError: array must not contain infs or NaNs
</code></pre></div>
<p dir="auto">Currently, RandomForestRegressor and friends perform a reduction by means of a simple averaging over the population.</p>
<p dir="auto">In the past, I have written code to compute the mode over a set of votes; currently, I would like to experiment with using a trimmed mean. But there isnt any reduction operation that I cant see as being potentially useful to experiment with.</p>
<p dir="auto">Is that intuition wrong? Are there good arguments in the literature why a mean is always the interesting metric to reduce your population by? And if not, are there any good implementational reasons why this wouldnt fit well into sklearn? There will be some memory and runtime overhead for more complex reductions, but no show stoppers that I can see</p>
<p dir="auto">If not, are there any other issues/PRs that overlap with this? I might try my hand at implementing something like this myself.</p>