Target encoding (aka mean or categorical encoding) converts a categorical independent variable to a continuous response for use in predictive modelling. In its most basic form, it does this by calculating the mean of the continuous dependent variable over all training samples in a given class, and this mean becomes the assigned value of the dependent variable for all cases in that class. The main problem with this approach is that it can overfit the modelled response, and a number of solutions (e.g. k-fold cross-validated calculation of class means) are used to circumvent the problem.

My question is a theoretical one, and its this: Is overfitting still a risk if instead of the estimated response means I use the true population response means for each class? So in the simplified example below the yellow rows are my sample and all rows are the full population (not normally available to the modeller obviously). Standard encoding (Enc1) assigns the mean of Response in the yellow rows in a given Class to each sample observation in that class. Enc2 gets its values by calculating the mean Response across all Response values in the population in that class and is the alternative approach I query above.

Example data. Enc1= mean Response in yellow rows of the given Class. Enc2= mean Response in all rows of the given Class

The reason I'm asking is that I'm modelling samples from satellite imagery, and its actually possible for me to calculate population rather than sample response means. As such, I'm wondering if this might be a better approach to avoid overfitting.




Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.