<div class="snippet-clipboard-content notranslate position-relative overflow-auto" data-snippet-clipboard-copy-content="from sklearn.ensemble import RandomForestClassifier

X = np.ones(shape=(0,1))
y = np.ones(shape=(0,1))

rfc = RandomForestClassifier()

In [36]: rfc.fit(X,y)
---------------------------------------------------------------------------
ValueError                                Traceback (most recent call last)
&lt;ipython-input-36-eec77b0a9246&gt; in &lt;module&gt;()
----&gt; 1 rfc.fit(XX,yy)

/usr/local/lib/python2.7/site-packages/sklearn/ensemble/forest.pyc in fit(self, X, y, sample_weight)
    363                 random_state.randint(MAX_INT),
    364                 verbose=self.verbose)
--&gt; 365             for i in xrange(n_jobs))
    366 
    367         # Reduce

/usr/local/lib/python2.7/site-packages/sklearn/externals/joblib/parallel.pyc in __call__(self, iterable)
    512         try:
    513             for function, args, kwargs in iterable:
--&gt; 514                 self.dispatch(function, args, kwargs)
    515 
    516             self.retrieve()

/usr/local/lib/python2.7/site-packages/sklearn/externals/joblib/parallel.pyc in dispatch(self, func, args, kwargs)
    309         &quot;&quot;&quot;
    310         if self._pool is None:
--&gt; 311             job = ImmediateApply(func, args, kwargs)
    312             index = len(self._jobs)
    313             if not _verbosity_filter(index, self.verbose):

/usr/local/lib/python2.7/site-packages/sklearn/externals/joblib/parallel.pyc in __init__(self, func, args, kwargs)
    133         # Don't delay the application, to avoid keeping the input
    134         # arguments in memory
--&gt; 135         self.results = func(*args, **kwargs)
    136 
    137     def get(self):

/usr/local/lib/python2.7/site-packages/sklearn/ensemble/forest.pyc in _parallel_build_trees(n_trees, forest, X, y, sample_weight, sample_mask, X_argsorted, seed, verbose)
     86                 curr_sample_weight = sample_weight.copy()
     87 
---&gt; 88             indices = random_state.randint(0, n_samples, n_samples)
     89             sample_counts = bincount(indices, minlength=n_samples)
     90 

/usr/local/lib/python2.7/site-packages/numpy/random/mtrand.so in mtrand.RandomState.randint (numpy/random/mtrand/mtrand.c:6443)()

ValueError: low &gt;= high"><pre class="notranslate"><code class="notranslate">from sklearn.ensemble import RandomForestClassifier

X = np.ones(shape=(0,1))
y = np.ones(shape=(0,1))

rfc = RandomForestClassifier()

In [36]: rfc.fit(X,y)
---------------------------------------------------------------------------
ValueError                                Traceback (most recent call last)
&lt;ipython-input-36-eec77b0a9246&gt; in &lt;module&gt;()
----&gt; 1 rfc.fit(XX,yy)

/usr/local/lib/python2.7/site-packages/sklearn/ensemble/forest.pyc in fit(self, X, y, sample_weight)
    363                 random_state.randint(MAX_INT),
    364                 verbose=self.verbose)
--&gt; 365             for i in xrange(n_jobs))
    366 
    367         # Reduce

/usr/local/lib/python2.7/site-packages/sklearn/externals/joblib/parallel.pyc in __call__(self, iterable)
    512         try:
    513             for function, args, kwargs in iterable:
--&gt; 514                 self.dispatch(function, args, kwargs)
    515 
    516             self.retrieve()

/usr/local/lib/python2.7/site-packages/sklearn/externals/joblib/parallel.pyc in dispatch(self, func, args, kwargs)
    309         """
    310         if self._pool is None:
--&gt; 311             job = ImmediateApply(func, args, kwargs)
    312             index = len(self._jobs)
    313             if not _verbosity_filter(index, self.verbose):

/usr/local/lib/python2.7/site-packages/sklearn/externals/joblib/parallel.pyc in __init__(self, func, args, kwargs)
    133         # Don't delay the application, to avoid keeping the input
    134         # arguments in memory
--&gt; 135         self.results = func(*args, **kwargs)
    136 
    137     def get(self):

/usr/local/lib/python2.7/site-packages/sklearn/ensemble/forest.pyc in _parallel_build_trees(n_trees, forest, X, y, sample_weight, sample_mask, X_argsorted, seed, verbose)
     86                 curr_sample_weight = sample_weight.copy()
     87 
---&gt; 88             indices = random_state.randint(0, n_samples, n_samples)
     89             sample_counts = bincount(indices, minlength=n_samples)
     90 

/usr/local/lib/python2.7/site-packages/numpy/random/mtrand.so in mtrand.RandomState.randint (numpy/random/mtrand/mtrand.c:6443)()

ValueError: low &gt;= high
</code></pre></div>
<p dir="auto">Also for decision trees:</p>
<div class="snippet-clipboard-content notranslate position-relative overflow-auto" data-snippet-clipboard-copy-content="from sklearn.tree import DecisionTreeClassifier

X = np.ones(shape=(0,1))
y = np.ones(shape=(0,1))

dtc = DecisionTreeClassifier()
dtc.fit(X,y)

---------------------------------------------------------------------------
ValueError                                Traceback (most recent call last)
&lt;ipython-input-41-bd6795874945&gt; in &lt;module&gt;()
----&gt; 1 dtc.fit(X,y)

/usr/local/lib/python2.7/site-packages/sklearn/tree/tree.pyc in fit(self, X, y, sample_mask, X_argsorted, check_input, sample_weight)
    358                          sample_weight=sample_weight,
    359                          sample_mask=sample_mask,
--&gt; 360                          X_argsorted=X_argsorted)
    361 
    362         if self.n_outputs_ == 1:

/usr/local/lib/python2.7/site-packages/sklearn/tree/_tree.so in sklearn.tree._tree.Tree.build (sklearn/tree/_tree.c:4823)()

/usr/local/lib/python2.7/site-packages/sklearn/tree/_tree.so in sklearn.tree._tree.Tree.build (sklearn/tree/_tree.c:4636)()

/usr/local/lib/python2.7/site-packages/sklearn/tree/_tree.so in sklearn.tree._tree.Tree.recursive_partition (sklearn/tree/_tree.c:5156)()

ValueError: Attempting to find a split with an empty sample_mask."><pre class="notranslate"><code class="notranslate">from sklearn.tree import DecisionTreeClassifier

X = np.ones(shape=(0,1))
y = np.ones(shape=(0,1))

dtc = DecisionTreeClassifier()
dtc.fit(X,y)

---------------------------------------------------------------------------
ValueError                                Traceback (most recent call last)
&lt;ipython-input-41-bd6795874945&gt; in &lt;module&gt;()
----&gt; 1 dtc.fit(X,y)

/usr/local/lib/python2.7/site-packages/sklearn/tree/tree.pyc in fit(self, X, y, sample_mask, X_argsorted, check_input, sample_weight)
    358                          sample_weight=sample_weight,
    359                          sample_mask=sample_mask,
--&gt; 360                          X_argsorted=X_argsorted)
    361 
    362         if self.n_outputs_ == 1:

/usr/local/lib/python2.7/site-packages/sklearn/tree/_tree.so in sklearn.tree._tree.Tree.build (sklearn/tree/_tree.c:4823)()

/usr/local/lib/python2.7/site-packages/sklearn/tree/_tree.so in sklearn.tree._tree.Tree.build (sklearn/tree/_tree.c:4636)()

/usr/local/lib/python2.7/site-packages/sklearn/tree/_tree.so in sklearn.tree._tree.Tree.recursive_partition (sklearn/tree/_tree.c:5156)()

ValueError: Attempting to find a split with an empty sample_mask.
</code></pre></div>
<p dir="auto">The handling of 1d input should be consistent in all estimators. I think currently 1d X is assumed to be of shape <code class="notranslate">(1, n_features)</code> - and even that might fail sometimes. That needs to be checked and needs to be consistent across all estimators.</p>
<p dir="auto">Also, all estimators that don't support nd-input (I'm not sure any do or should do?) need to raise an appropriate error.</p>