Lost in the Forest: Encoding categorical variables and the absent levels problem
Authors:
Open Access
- 10 April 2024
- journal article
- research article
- Published by Springer Nature in Data Mining and Knowledge Discovery
- Vol. 38 (4) , 1889-1908
Abstract
Levels of a predictor variable that are absent when a classification tree is grown can not be subject to an explicit splitting rule. This is an issue if these absent levels are present in a new observation for prediction. To date, there remains no satisfactory solution for absent levels in random forest models. Unlike missing data, absent levels are fully observed and known. Ordinal encoding of predictors allows absent levels to be integrated and used for prediction. Using a case study on source attribution of Campylobacter species using whole genome sequencing (WGS) data as predictors, we examine how target-agnostic versus target-based encoding of predictor variables with absent levels affects the accuracy of random forest models. We show that a target-based encoding approach using class probabilities, with absent levels designated the highest rank, is systematically biased, and that this bias is resolved by encoding absent levels according to the a priori hypothesis of equal class probability. We present a novel method of ordinal encoding predictors via principal coordinates analysis (PCO) which capitalizes on the similarity between pairs of predictor levels. Absent levels are encoded according to their similarity to each of the other levels in the training data. We show that the PCO-encoding method performs at least as well as the target-based approach and is not biased.Keywords
All Related Versions
Funding Information
- Massey University
- Massey University
This publication has 42 references indexed in Scilit:
- Source attributed case-control study of campylobacteriosis in New ZealandInternational Journal of Infectious Diseases, 2021
- Similarity encoding for learning with dirty categorical variablesMachine Learning, 2018
- Source attribution of human campylobacteriosis using a meta-analysis of case-control studies of sporadic infectionsEpidemiology and Infection, 2012
- The Elements of Statistical Learning2009
- Hamming Distance2009
- Comparison of genomic sequences using the Hamming distanceJournal of Statistical Planning and Inference, 2005
- Random ForestsMachine Learning, 2001
- Partitioning Nominal Attributes in Decision TreesData Mining and Knowledge Discovery, 1999
- Bagging predictorsMachine Learning, 1996
- Basic local alignment search toolJournal of Molecular Biology, 1990