1
$\begingroup$

Consider this question on a survey:

What desserts have you eaten?

  • Apple pie
  • Banana pudding
  • Coconut cake
  • Doughnut holes

The user can pick as many of the options as they like. How would one encode this for use in a machine learning model? One-hot encoding is not viable in general, as there are $2^n-1$ unique combinations of options which quickly becomes unmanageable. In my case I have multiple questions with 20 options each, even one of those features would get one-hot encoded into $2^{20}-1\approx 1000000$ binary features. Ordinal encoding with increasing integers also does not seem appropriate given that the different sets of options do not have an inherent ordering to them.

One option is to make a binary feature for whether or not the user included a particular option in their selection. If there are a total of $n$ possible options to select, this results in $n$ binary features.

Are there any other good approaches?

$\endgroup$

1 Answer 1

1
$\begingroup$

Make each of the twenty questions its own factor variable. Some of them might still have very many levels, for ideas how to handle that see Principled way of collapsing categorical variables with many levels?.

For better answers, you should augment your question with some more information, sample size? Are all the possible choices used by some participants? If so you must have a large sample --- other idea could be some dimension reduction, look into multiple correspondence analysis --- GLM with scores/principal dimensions from MCA, How can I use projections (components) from multiple correspondence analysis in subsequent regression analysis, similar to PCA

$\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.