title: classifiers in scikit-learn that handle nan/null
body: <p>I was wondering if there are classifiers that handle nan/null values in scikit-learn.  I thought random forest regressor handles this but I got an error when I call <code>predict</code>.</p>
  
  <pre><code>X_train = np.array([[1, np.nan, 3],[np.nan, 5, 6]])
  y_train = np.array([1, 2])
  clf = RandomForestRegressor(X_train, y_train)
  X_test = np.array([7, 8, np.nan])
  y_pred = clf.predict(X_test) # Fails!
  </code></pre>
  
  <p>Can I not call predict with any scikit-learn algorithm with missing values?</p>
  
  <p><strong>Edit.</strong>
  Now that I think about this, it makes sense.  It's not an issue during training but when you predict how do you branch when the variable is null?  maybe you could just split both ways and average the result?  It seems like k-NN should work fine as long as the distance function ignores nulls though.</p>
  
  <p><strong>Edit 2 (older and wiser me)</strong>
  Some gbm libraries (such as xgboost) use a ternary tree instead of a binary tree precisely for this purpose: 2 children for the yes/no decision and 1 child for the missing decision. sklearn is <a href="https://github.com/scikit-learn/scikit-learn/blob/master/sklearn/tree/_tree.pyx#L70-L74" rel="noreferrer">using a binary tree</a></p>