Most models need numbers, but real data is full of categories: country, product type, colour. How you encode them matters.
One-Hot Encoding
Create one binary column per category. colour = red becomes red=1, green=0, blue=0. It makes no assumption about order and is the safe default for categories with a modest number of values. Handle unseen categories at prediction time (handle_unknown="ignore").
Ordinal Encoding
Map categories to integers. Appropriate only when there is a natural order — small < medium < large. For unordered categories it invents a false ranking, though tree models often cope.
Target Encoding
Replace each category with the average target value for that category. Powerful for high-cardinality features such as postcodes, but prone to leakage and overfitting; compute it within cross-validation folds and add smoothing toward the overall mean.
Hashing
Hash categories into a fixed number of columns. Useful for huge or open-ended vocabularies, at the cost of occasional collisions and less interpretability.
Frequency Encoding
Replace each category with how often it occurs. Simple and sometimes surprisingly informative.
Rare Categories
Group very rare categories into an "other" bucket before encoding, so the model isn't fitting to a handful of examples.
Native Support
Some libraries — CatBoost, LightGBM and scikit-learn's histogram gradient boosting — handle categorical features directly and often do it well.