0
$\begingroup$

I would like to understand if there is the possibility to encode the days of the week as a single numerical column to preserve the ordinal relationship between the days.

My task is a classification task.

So, something like this:

  • Monday: 0
  • Thrusday: 1
  • Wednesday: 2
  • ...
  • Sunday: 6

I wouldn't use a one-hot encoding for this scenario because I would like to preserve the ordinal relationship between the days.

However, I don't know if this is an allowed approach or not.

$\endgroup$
0
$\begingroup$

The answer is as follows: If you are using a Linear Regression Model - then it will assume that Sunday (6) is bigger (or carries more weight) than all other days in the week. If that assumption makes sense for your problem domain - you are fine.

If you are using a model such as Random Forests - then it doesn't really matter (meaning you are good). Random Forests are typically scale invariant - They do not assume higher weightage for large values - They will figure out how best to split up the numeric values (0 - 6) to meet your objective.

$\endgroup$
1
  • $\begingroup$ I'm not using any kind of regression, only classification algorithm (like random forests), so it might work well. $\endgroup$ – xcsob Apr 6 at 16:44

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.