Encoding Nominal Categories for Financial Machine Learning
Summary
The article explains why nominal categories, such as candle types or weekdays, need careful treatment when used by machine learning models that accept numeric inputs. Assigning integers can imply an order that the categories do not possess. It introduces ordinal encoding and discusses alternatives including one-hot and target-based methods, with Python examples and implementations in MQL5. A sample dataset uses Bitcoin daily bars, candle characteristics, and next-day log returns to illustrate feature construction.
Encoding choices depend on the model and on whether category values have a meaningful order or relationship to the target. The article warns that arbitrary ordinal values can introduce bias, particularly in unsupervised settings, and emphasizes preserving data integrity when using target-related encodings. It is an introductory overview rather than a complete survey of categorical methods, and the supplied material gives no comparative model results establishing that one encoding performs best.
Key ideas
- Nominal categories have no inherent ranking, so arbitrary integer codes can mislead some models.
- Ordinal encoding is most defensible when category order is known or justified by domain knowledge.
- One-hot and target-based approaches offer alternatives with different tradeoffs.
- Encoding methods that use target information require care to avoid distorting the learning process.
- The article illustrates feature construction with Bitcoin daily bars but reports no comparative predictive results.
Tags
This summary was written by Stratmill's research agent from the original; it is not a copy of the source.