When is simple target encoding optimal? Moment exactness for sparse categorical features, and the limits of estimating their information
–arXiv.org Artificial Intelligence
Target encoding replaces each level of a high-cardinality categorical feature by a smoothed estimate of the target rate. We ask how well any encoder can do when most test rows fall on levels seen zero, one or two times, what a simple encoder misses on real data, and whether the information I(X; Y) the feature carries can be estimated in the same regime. The Bayes prediction after n observations depends only on the first n + 1 moments of the prior of the target rates. Hence, when the target rate of a level does not depend on its popularity (exchangeability), a beta prior matched to two moments is exactly the oracle on levels seen at most once; fitting it by type-II maximum likelihood recovers it asymptotically when no level is seen more than twice, and stays numerically close otherwise when levels are equally popular. A moment test rejects exchangeability on 21 of 23 real features. Without it, the oracle prior for levels seen n times is the law of the target rate among levels seen n + 1 times; this shift gives a correction for levels seen at most once that is read off the singleton and doubleton counts, and a frequency-aware prior that closes half to four-fifths of the remaining gap on the real-data subsampling oracles with popularity dependence. Information is harder: from levels seen at most L times, I(X; Y) is only partially identified, within a worst-case half-width of 0.038 nats for L = 2 and about 0.22/L2 nats for larger even L, and without exchangeability only a trivial bound is identified for the singletons' share. In single-feature prediction on 24 real features, the fitted priors (beta, NPMLE, posterior-mean GLMM, frequency-aware, beta with the correction) differ from each other by less than 0.01 nats per test row, though by up to 15% of the beta's gain on some sparse features; larger losses come from a fixed smoothing strength far from the fitted one, such as the common default m = 20 on sparse click features, and from predicting a GLMM at its conditional mode. A likelihood-region interval for I(X; Y) covers in our synthetic studies and on all but one exchangeable real-data pool; on real features, where exchangeability fails, stratified identified intervals, which assume it only within groups of level sizes and ignore sampling error, are several hundredths of a nat wide on sparse features and up to 0.45 nats on the sparsest.
arXiv.org Artificial Intelligence
Nov-30-2026