title: Encoding categorical variables that do not have a rank/order for classification?
body: <p>I have primarily worked with classification problems that have numerical features size, height, weight, distance, times, bag of words/tf-idf, so on.  However, I am starting to consider working with more datasets that has categorical features. Examples of such features are race, genre (book or movie), color, shape, city name, school, etc. If I had a categorical variable called length that had the levels small, medium, large, it makes sense to recode that as 1, 2, 3 since there is already some hierarchy or order present. However, I am confused about encoding variables that do not have a natural translation to a numerical scale or already have an intrinsic sense of order. </p>
  
  <p>With something like color, imagine the options are red, green, and blue. It does not make sense for red to be 1, green to be 2, and blue to be 3, because that means that red is technically "closer" to green than blue and what does it mean in this case for color to be ranked or have distance? Similarly, imagine we have a simplified list of genres (romance, comedy, drama, scifi, action). If I encode that as romance - 1, comedy - 2, drama - 3, scifi - 4, action - 5, that means in this representation romance is "closer" or more similar to comedy than drama, which really does not make sense. I feel by doing this, we're artificially creating structure and meaning that is not already present.</p>
  
  <p>If you think that encoding in this manner is totally acceptable, I would love to be proved wrong (it would be much more convenient and simple to work with) -- please just explain why. If my interpretation is correct, can you explain how I can address this? What are examples of things that you have done (or commonly accepted practices)? I realize that binary variables are fairly straightforward with the examples above, but not necessarily if I have significantly more options. Note: I primarily work with Python, Pandas, and Sklearn for ML. If you suggest other tools that can help with this, let me know.</p>
  
  <p>Thank you!</p>