0
$\begingroup$

I've been exploring methods for encoding categorical data. I was hoping to find a good method that does not increase the dimension of the dataset, similar to the one used on this dataset about drug use: Drug consumption (quantified) Data Set

Each piece of categorical data in this dataset was converted to some real number, but yet the dimension of the dataset was not increased. Instead of just randomly replacing values with numbers, there appears to be some thought out method behind this. Can anyone shed some light on this matter?

$\endgroup$

2 Answers 2

2
$\begingroup$

There are several different types of categorical data. For example, the severity of trauma or psychological scale is not categorical by nature: there is a latent continuous feature that was converted to discrete. In such a case described quantification is absolutely reasonable.

For the non-ordered (nominal) attributes (for example, country or ethnicity) any quantification mostly meaningless and really can create bias and introduce artificial order.

For the discussed database most of the attributes were ordinal. Two nominal attributes were helpless in any coding: we tested dummy coding and CatPCA based coding.

Really, as Erwan wrote, each time it is necessary to analyze variables and then decide how to encode it.

$\endgroup$
1
  • $\begingroup$ Wow! Thank you so much for posting this answer! Really made my day :-) $\endgroup$
    – Mr.Young
    Nov 29, 2019 at 10:39
2
$\begingroup$

I would strongly advise against doing anything like this: a features which is semantically discrete should be typed as such. There's nothing to be gained about casting categorical values into real numbers:

  • It obfuscates the meaning to a human analyzer
  • For categorical variables which are not ordinal (i.e. have no natural order), it introduces a serious bias for learning algorithms (note: most attributes in the dataset mentioned in the question are ordinal).
  • Real number binary representation can lead to approximations, thus possible errors when used as labels and compared for strict equality (something that a categorical variable should support)
  • It becomes impossible to fix errors in the data

Any conversion in the data should always rely on reasons which are specific to the problem/method to be used, not on some agnostic technical transformation. There's no universal recipe for encoding features (categorical or other), one has to understand what they represent and how an algorithm could use them in order to determine the best representation.

$\endgroup$
6
  • $\begingroup$ Thanks for the answer. So do you think that the folks who did the conversions for that dataset did unwise thing? $\endgroup$
    – Mr.Young
    Nov 24, 2019 at 1:36
  • $\begingroup$ @Mr.Young yes, that's certainly my first impression. At the very least I would expect a clear explanation about it since this is very unorthodox, but I read (quickly) through the description and didn't find any. If there was a logic behind it, I'd be curious to know it. $\endgroup$
    – Erwan
    Nov 24, 2019 at 1:47
  • $\begingroup$ I looked all over the place trying to find an explanation. That's why I posted the question. I'm hoping that someone recognizes the method and will explain a little bit about it. Maybe I should email this post to the authors of the dataset. $\endgroup$
    – Mr.Young
    Nov 24, 2019 at 1:57
  • $\begingroup$ I just emailed Dr. Mirkes from the Department of Mathematics at the University of Leicester. He is the one that donated the dataset to the UCI Machine Learning Repository. If he emails me back, I will post his answer. If we're luck, he may just come on here and post the answer himself. $\endgroup$
    – Mr.Young
    Nov 24, 2019 at 2:18
  • $\begingroup$ Ok let's see if they answer $\endgroup$
    – Erwan
    Nov 24, 2019 at 14:53

Your Answer

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

Not the answer you're looking for? Browse other questions tagged or ask your own question.