0
$\begingroup$

I am working on a dataset which is pretty small: 1169 records.

There is a column called month and it takes the values 'Jan','Feb', or 'March'.

The number of records for each month is different. I have 542 for 'Jan', 443 for 'Feb', and 212 for 'March'.

Given this information, should I use one hot encoding or encode the months as 1,2,3 for Jan, Feb, March respectively? Will the higher value account for the fact that there there are fewer records for that month?

$\endgroup$

1 Answer 1

0
$\begingroup$

Whether you one-hot encode is unrelated to the number of records for each month.

Some algorithms are happy to create categoricals as categoricals directly, like most tree-based methods. They may want them encoded as numbers, but, the numbers themselves do not (should not) have meaning. They're just indices. 0-11 or 1-12 should be fine.

One-hot encoding is necessary when using a method that can't deal with categoricals, like linear methods. You would not want to encode months as numbers in the case. You have to one-hot encode, really. Otherwise "Dec" is "12 times larger" than "Jan" which almost always doesn't make sense semantically.

$\endgroup$

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.