2
$\begingroup$

So I was searching on how to handle missing data and came across this post from Machine Learning Mastery.

This article states that some algorithms can be made robust to missing data, such as Naive Bayes and KNN.

Not all algorithms fail when there is missing data.
There are algorithms that can be made robust to missing data, such as k-Nearest Neighbors that can ignore a column from a distance measure when a value is missing. Naive Bayes can also support missing values when making a prediction.

But then it says that sklearn implementations are not robust to missing data.

Sadly, the scikit-learn implementations of Naive Bayes, decision trees, and k-Nearest Neighbors are not robust to missing values.

Are there ML libs (preferably in Python, but could also be in other languages) that these algorithms are robust to missing data?

$\endgroup$

4 Answers 4

0
$\begingroup$

In general Weka can handle missing values, which are marked as ? in the .arff format. However this doesn't mean that every learning algorithm in Weka has a specific mechanism to deal with them, and unfortunately the documentation is a bit poor about this point. So as far as I'm aware, one has to study the source code and/or do some experiments in order to find out exactly what a particular class does with missing values.

Weka is in Java but there is a wrapper for Python.

$\endgroup$
0
$\begingroup$

As far as I know, the only algorithm that supports NaN's in scikit-learn / Python is the HistGradientBoostingClassifier this might be used by setting:

# explicitly require this experimental feature
from sklearn.experimental import enable_hist_gradient_boosting  # noqa
# now you can import normally from ensemble
from sklearn.ensemble import HistGradientBoostingClassifier

but this is still on experimental phase.

From scikit-learn documentation:

This estimator has native support for missing values (NaNs). During training, the tree grower learns at each split point whether samples with missing values should go to the left or right child, based on the potential gain. When predicting, samples with missing values are assigned to the left or right child consequently. If no missing values were encountered for a given feature during training, then samples with missing values are mapped to whichever child has the most samples. This implementation is inspired by LightGBM.

enter image description here

$\endgroup$
0
$\begingroup$

I would like to add that apart from ML libs being robust to (can handle rather) Nan values, such as XGBoost, kNN implementations, there are also missing data imputation techniques. Which once you implement them you can try any ML algorithm. However, there are a few of them and you have to see what works best. For reference, you can look at hot deck imputation.

$\endgroup$
0
$\begingroup$

There are a couple scikit learn implementations of CatBoost and LGBM(not sure about this one) that are robust to nan values. I am sure catboost can handle nan values.

$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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