0
$\begingroup$

I have a dataset where the task is to classify whether someone looking for a new job will leave their current job, based on a number of factors. (dataset: https://www.kaggle.com/arashnic/hr-analytics-job-change-of-data-scientists)

I'm trying to encode the data and one of the things I struggle with is how to decide whether data is categorical, ordinal.

For example, one of the columns is called 'education_level', and has 5 levels, 'phd', 'masters', 'graduate', 'high school', 'primary school'.

Now if I were to encode this naively, then I'd say it was an ordinal variable because a phd is usually better than a masters, etc. However, I'm struggling to decide whether this is in fact the best way, or, is one-hot encoding more suitable.

The reason is because I don't think I'm trying to rank the candidates by suitability, I'm merely trying to predict whether they will leave their current job, so it doesn't really make sense to me to say that a phd is better than any other level of education. It seems more like an 'arbitrary' partition in this context.

Am I right in thinking that one-hot encoding is better in a situation like this? Or am I simply overthinking and should just go with the naive definition?

EDIT: I read the answer to this question: What is an example of how ordinal data can yield bad classification results in contrast with one-hot encoding?

and have tried to apply it to my problem.

So by using ordinal encoding, I would be enforcing the relationship

$$\hat{y}_{phd} > \hat{y}_{mas} > \hat{y}_{grad} > \hat{y}_{high} > \hat{y}_{prim}$$.

Since I have a classification problem, I'm modelling probabilities, so the implication is that I'm enforcing the constraint that phd's have a higher probability of leaving their job without knowing whether that is true or not. Therefore, I need to use one-hot encoding.

Is this logic sound?

$\endgroup$
7
  • $\begingroup$ Phd and masters are both graduate, so your set of values is not ordinal $\endgroup$
    – Aksakal
    Commented Dec 6, 2021 at 23:23
  • 1
    $\begingroup$ Yes that is true. So this means that I must label all masters as both masters and graduate? But in doing so, does it not imply an ordinal structure because the predictions would have an extra contribution from the masters variable on top of the grad variable? $\endgroup$
    – ryan132442
    Commented Dec 6, 2021 at 23:34
  • $\begingroup$ What is your sample size? If that gives sufficient degrees of freedom, just go for one-hot. $\endgroup$ Commented Dec 7, 2021 at 12:46
  • $\begingroup$ I'd start with definitions. in American English graduate adjective means education levels after undergarduate such as BS or BA degrees. Examples of graduate would be Masters and Doctorate. Perhaps, in your data it means something else since you don't have undergraduate level. I saw in some countries doctorate is referred as post-graduate. I suspect that after you sort this out, your levels may become cardinal $\endgroup$
    – Aksakal
    Commented Dec 7, 2021 at 13:24
  • $\begingroup$ @kjetilbhalvorsen There are almost 20000 samples so the DoF would not be a problem. But I'm also looking for how to think about these situations in general. $\endgroup$
    – ryan132442
    Commented Dec 7, 2021 at 22:20

0

Your Answer

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