liveBook · Manning

Mean target encoding

As explained in Machine Learning System Design

Target encoding is a categorical-variable encoding technique that replaces each category with a statistic of the target values associated with that category.

Mean target encoding replaces each category with the mean target value associated with that category, usually with some regularization. It offers an alternative to one-hot, ordinal, and hashing-based encodings for categorical features. section 11.1.2 section 11.1.3

Use it with an explicit leakage check:

  • Treat the encoded category statistic as a feature for the downstream model. section 11.1.3
  • Prevent the encoding from using target information unavailable during inference; otherwise, overfitting and poor new-data performance can result. section 11.1.2 section 11.1.3
  • Use advanced validation techniques such as nested cross-validation when evaluating the feature. section 11.1.3

Categorical features in ETA prediction

An ETA system can combine continuous, categorical, and geospatial inputs. Categorical inputs may be transformed through mean target encoding or other categorical encodings before entering a machine-learning model; DeepETA illustrates a broader pipeline that converts diverse tabular inputs into discrete tokens and learnable embeddings. section 11.1.2

How Machine Learning System Design covers it

How deep it goes
Defines regularized category-wise target means and flags leakage, but does not detail the encoding algorithm.
Examples
Uses mixed tabular features in ETA prediction and contrasts mean target encoding with one-hot, ordinal, and hashing transformations.
What you can do after
Evaluate target-encoded features while checking leakage and applying nested cross-validation.
How it connects
Connects categorical encoding with one-hot encoding, ordinal encoding, hashing, model stacking, and nested cross-validation.

Also explained in

Compare how 3 books explain mean target encoding →

Related concepts

This explainer was generated by Manning's knowledge graph from the text of Machine Learning System Design. The section links point to the parts of the book it draws on.