I am reading a presentation and it recommends not using leave one out encoding, but it is okay with one hot encoding. I thought they both were the same. Can anyone describe what the differences between them are?


1 Answer 1


They are probably using "leave one out encoding" to refer to Owen Zhang's strategy.

From here

The encoded column is not a conventional dummy variable, but instead is the mean response over all rows for this categorical level, excluding the row itself. This gives you the advantage of having a one-column representation of the categorical while avoiding direct response leakage

This picture expresses the idea well. enter image description here

  • 1
    $\begingroup$ Your explanation is better than wacax's in the referred link, thank you $\endgroup$
    – Allan Ruin
    Aug 12, 2016 at 15:00
  • $\begingroup$ Hi @Dex Groves, so the leave_one_out encoding for the test is always .5? $\endgroup$ Mar 24, 2017 at 20:29
  • 3
    $\begingroup$ Hi! As seen from the picture, this paticular example relates to classification problem. Does anybody have an experience with LOO encoding within regression problem? The main question is how to aggregate the target variable. I am now making experiments and get huge overfitting with mean(y). $\endgroup$ Jun 19, 2017 at 12:49
  • 1
    $\begingroup$ for a clustering (unsupervised) problem, is possible to use this kind of encoding? $\endgroup$
    – enneppi
    Sep 13, 2018 at 10:26
  • 1
    $\begingroup$ @enneppi - the whole idea is to "tie" your categorical feature to the target "y", which you're missing in your unsupervised ML. You could try "tying" your categorical feature into other X features (a kind of feature engineering) $\endgroup$
    – mork
    Mar 18, 2019 at 8:46

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.