2
$\begingroup$

This is a general question, but I will provide a real scenario that occurred which prompted me to ask this question:

I took over a project and noticed that one of the variables "conflict event type" has a basic structure of "less violent" -> "more violent" over 6 levels from "protests" -> "battles" and am wondering if I should leave it as is or convert to label encoding.

I had, up to this point, always created an ordered mapping to encode ordinal categories. It never crossed my mind to do otherwise. I thought "Well, if the order isn't helpful, then the neural network will likely marginalize it anyway."

I realized that I don't have any evidence that this is true, and have never read it anywhere.

So, in general, is there ever a reason to one-hot encode data that has an obvious underlying order?

$\endgroup$
9
  • 3
    $\begingroup$ You may get more responses if you use standard terminology in the post title, instead of jargon. $\endgroup$ Commented Nov 1, 2020 at 11:24
  • 2
    $\begingroup$ You should really give more context to your application. Even if there is an order to your conflict event type, based on degree of violence, how can you be sure that there is "degree of violence" that is important for your outcome? You did not even tell us your outcome. $\endgroup$ Commented Nov 1, 2020 at 13:05
  • 1
    $\begingroup$ In general it depends on what you do with the encoded data. If you apply a method that assumes that the connection between the ordinal variable and the response is monotonic but in fact it's not, one-hot encoding may help (although it's probably not the only option). $\endgroup$ Commented Nov 1, 2020 at 16:36
  • 3
    $\begingroup$ Don't shout at benevolent and respected users of this community, please, especially when they only request some clarifications (the term jargon is not pejorative, and I believe one-hot encoding is restricted to very particular applications in the ML world). $\endgroup$
    – chl
    Commented Nov 1, 2020 at 17:47
  • 1
    $\begingroup$ I know one-hot encoding (or dummy-coding, which is more common in statistical modeling), and more generally what variable encoding/recoding means. But that's okay, do what you want with my advice. $\endgroup$
    – chl
    Commented Nov 1, 2020 at 17:53

1 Answer 1

3
$\begingroup$

You really need to give more context to your question for a really useful answer. In general, questions like this are difficult to answer in the abstract, only some generalities can be said.

I will assume your conflict event type variable is to be used as an predictor (I assume that is input in machine learning lingo.) Even if that variable can be ordered along a line of less to more violence, that does not mean it is necessarily that is the only aspect of the variable that is important for the response (output.) So why not try it both ways and see what works best for your goal? That is, one model with dummy (one-hot) encoding, another with 1,2,3,4,5,6 numerical coding and a spline or low-order polynomial. Then see what works best.

Also see Including both transformed and original data (untransformed) in a multivariable linear regression..

$\endgroup$
1
  • 1
    $\begingroup$ So essentially the answer to my question is yes (as this was a general yes or no question). To expand on simply 'yes', there are times where one-hot encoding ordinal data is an appropriate tactic. When to do it depends on the specific context of a given problem/task, but in general if one is not sure he or she can always try both one-hot and label encoding and compare the performance of the two... This would have been a perfectly useful answer to my question. $\endgroup$ Commented Nov 12, 2020 at 23:24

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.