[Paper Review] Sampling Techniques in Bayesian Target Encoding
This paper proposes Sampling Bayesian Encoder, a novel method for categorical variable encoding that improves generalization and reduces target leakage by sampling from the posterior distribution of target statistics instead of using fixed moments. It outperforms traditional target encoding and Bayesian target encoding in both synthetic and real-world datasets, achieving higher accuracy with better feature importance calibration.
Target encoding is an effective encoding technique of categorical variables and is often used in machine learning systems for processing tabular data sets with mixed numeric and categorical variables. Recently en enhanced version of this encoding technique was proposed by using conjugate Bayesian modeling. This paper presents a further development of Bayesian encoding method by using sampling techniques, which helps in extracting information from intra-category distribution of the target variable, improves generalization and reduces target leakage.
Motivation & Objective
- To address target leakage and overfitting in traditional target encoding by leveraging Bayesian inference.
- To improve generalization in high-cardinality categorical variables by capturing intra-category target distribution beyond just the mean.
- To develop a theoretically grounded, sampling-based alternative to moment-based Bayesian target encoding.
- To reduce reliance on heuristic noise injection by naturally exploring parameter space through sampling.
- To empirically validate the method on synthetic and real-world datasets across diverse ML models.
Proposed method
- The method models the target variable's distribution for each category using conjugate priors and updates them with training data to obtain a posterior distribution.
- Instead of using the first Q moments of the posterior, it samples from the posterior distribution to generate encoded representations.
- The encoding function f(θ) maps posterior parameters to a Q-dimensional space, enabling flexible representation learning.
- Model predictions are estimated via Monte Carlo averaging over K posterior samples: ŷ(xₙ) ≈ (1/K)Σŷ_θ(ξₙ, f₁(θₙ₁ᵏ), ..., fₘ(θₙₘᵏ)).
- Sampling is performed during both training and inference, with K samples per example, effectively increasing dataset size to K×N.
- The approach supports any predictive model and allows for adaptive feature engineering through the choice of f(θ), such as polynomials or weight of evidence.
Experimental results
Research questions
- RQ1Can sampling from the posterior distribution in Bayesian target encoding lead to better generalization than using fixed moments?
- RQ2Does the proposed sampling-based method reduce target leakage compared to standard target encoding and LeaveOneOutEncoder?
- RQ3How does the number of samples K affect model performance and training efficiency?
- RQ4To what extent does the choice of mapping function f(θ) impact model performance, especially for less expressive models?
- RQ5How does the prior scaling factor γ influence model robustness, particularly for rare categories?
Key findings
- On the make_classification dataset, the Sampling Bayesian Encoder achieved 0.6595 accuracy with Random Forest, slightly outperforming the best LeaveOneOutEncoder model at 0.6585.
- On the make_hastie_10_2 dataset, the method achieved 0.8229 accuracy versus 0.8217 for the LeaveOneOutEncoder baseline.
- On the Adult dataset, the method reached 0.8652 accuracy, compared to 0.8647 for the best LeaveOneOutEncoder model.
- On the Mercedes-Benz dataset, the R² score was 0.61135 with the proposed method, compared to 0.60974 for the LeaveOneOutEncoder.
- Feature importance analysis showed that the model using the Sampling Bayesian Encoder assigned significantly less importance to categorical features, indicating reduced target leakage.
- The method demonstrated improved performance on both public and private test sets in a competition setting, confirming better generalization to unseen data.
Read this paper
Open the full text in the Nubint reader and ask about any passage as you read.
Read this paper on NubintThis review was generated by AI from the original paper. Please check the paper before citing it.