I am attempting to build a model that has many predictors which are both categorical and large in cardinality. Target encoding looks to be a good solution for including these features, but I'm unsure of how to productionize the mapping if k-fold target encoding is used to avoid overfitting as described below:
Say 5 folds are divided at random; each category in each feature will then have 5 means in the training set. How do I decide which value to map to in production? My only thought is that the folds should be divided deterministically; then in production, we have a mapping for each fold definition - then each event that runs through our production model will have its fold calculated in realtime and mapped according to that value?
Image taken from: https://towardsdatascience.com/getting-deeper-into-categorical-encodings-for-machine-learning-2312acd347c8