# Handling Missing Values

**URL:** <https://community.drivendata.org/t/handling-missing-values/1051>\
**Category:** Pump it Up: Data Mining the Water Table\
**Created:** [April 18, 2017, 10:15am UTC](https://community.drivendata.org/t/handling-missing-values/1051 "2017-04-18T10:15:51Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![Ayiso](https://avatars.discourse-cdn.com/v4/letter/a/839c29/32.png) [@Ayiso](https://community.drivendata.org/u/Ayiso)\
**Post date:** [April 18, 2017, 10:15am UTC](https://community.drivendata.org/t/handling-missing-values/1051/1 "2017-04-18T10:15:51Z")

</div>

Hello guys

Anyone with a suitable technique that they utilized to handle missing categorical/ordinal values without distorting the data . This would be for variables like construction year , funder , installer etc

---

<div class="post-metadata">

**Author:** ![Gerard\_M](https://yyz2.discourse-cdn.com/flex028/user_avatar/community.drivendata.org/gerard_m/32/481_2.png) [@Gerard\_M](https://community.drivendata.org/u/Gerard_M)\
**Post date:** [April 20, 2017, 4:18pm UTC](https://community.drivendata.org/t/handling-missing-values/1051/2 "2017-04-20T16:18:02Z")

</div>

It depends on the algorithm which you are going to use: for logistic regression you should really take a sophisticated strategy. And use one-hot encoding.

For Gradient Boosting (XGBoost) I usually do the following: convert all the categorical values to numerical.  
In R: as.numeric(…)

After that: give the missing values a clearly separate value: for example -999.  
For a tree-algorithm this is enough to see if it should place missings in a separate branche of the trees which are generated.
