I've a binary classification problem which I want to solve where many features have a lot of missing values.

I know that imputing with mean/median/variance is a solution, but I'd like to run tests only with the original dataset without imputing. XGBoost allows the presence of missing values, while all the scikit-learn algorithms don't (correct me if I'm wrong), even if theoretically algorithm like random forest could accept missing values.

Other than XGBoost, which other python classification algorithms implementations allow the usage of a dataset with missing values?

  • $\begingroup$ Instead of trying to work with NaN values, most people either exclude the observations with missing data (which is bad) or use imputation (better). As always, the best strategy is to just collect complete data (but that's sometimes impossible because life is unfair). $\endgroup$
    – Sycorax
    Commented Mar 21, 2018 at 14:20
  • $\begingroup$ If I'd exclude observations with missing data, probably my dataset would end up being empty :) $\endgroup$ Commented Mar 21, 2018 at 14:22
  • $\begingroup$ @Sycorax I think NA and NaN are different things $\endgroup$
    – Haitao Du
    Commented Mar 21, 2018 at 14:28
  • 2
    $\begingroup$ allowing NaNs is just an euphemism to imputation of some sort $\endgroup$
    – Aksakal
    Commented Mar 21, 2018 at 14:29
  • 1
    $\begingroup$ @hxd1011 Depends on how NaNs arise. I'm assuming that OP didn't do something silly like take $\log(x)$ for a vector $x$ which contains 0s, or divide by zero... $\endgroup$
    – Sycorax
    Commented Mar 21, 2018 at 14:29

1 Answer 1


You can use the h2o package in python, it can deal with missing values.

Random Forest : http://docs.h2o.ai/h2o/latest-stable/h2o-docs/data-science/drf.html#faq

Gradient Boosting: http://docs.h2o.ai/h2o/latest-stable/h2o-docs/data-science/gbm-faq/missing_values.html

XGBoost: http://docs.h2o.ai/h2o/latest-stable/h2o-docs/data-science/xgboost.html#faqs


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.