I am currently getting ready to preprocess my data for scikitlearn and was wondering if I should use one hot encoding or label encoding when working with values greater than 9. I may be wrong but when it comes to one hot encoding it can only work on values 0-9.
Generally, depends on the model you are going to use later. If you are planning to use a tree-based model, then label-encoding (or even frequency-encoding) works fine. However, if you plan on using a linear model or Neural network, then one-hot encoding works better. Using one-hot encoding in tree-based models might unnecessarily increase complexity (See this link).
Always strategize your preprocessing so that it benefits the model you have chosen.
It depends on the meaning of the feature.
- If sorting labels makes sense
OrdinalEncoderis better choice (for example feature is
damage in ["no", "light", "medium", "severe"])
OneHotEncoderis a better choice (for example
color in ["blue", "yellow", "orange"])