Mean target encoding
Mean target encoding is a categorical encoding technique that replaces each category with the mean of its associated target values.
Ensemble Methods for Machine Learning
Greedy target encoding uses target-derived statistics computed from training data to encode categorical values, potentially introducing target leakage when the encoded examples contribute to those statistics.
- How it is used
- Encodes categorical features numerically for supervised classification and regression pipelines.
- How deep it goes
- Defines per-category target means, walks through a numeric example, and contrasts leakage mitigations without deriving their implementations.
- Examples
- Uses T-shirt color and cost means, Australian Credit Approval pipelines, and encoder comparisons with random forest, LightGBM, and XGBoost.
- What you can do after
- Apply it via category_encoders and evaluate it against alternative encoders with classification metrics.
Read how Ensemble Methods for Machine Learning explains mean target encoding →
Machine Learning for Tabular Data: XGBoost, Deep Learning, and AI
A feature encoding technique that replaces each category with a statistic computed from the target values associated with that category.
- How it is used
- Reduces high-cardinality categorical features to numeric target-derived features for tabular machine-learning models.
- How deep it goes
- Defines regression and classification statistics, explains smoothing and overfitting risk, and demonstrates pipeline integration without deriving the estimator.
- Examples
- Uses IDs, zip codes, product names, geographical names, and a binned latitude-longitude coordinates feature.
- What you can do after
- Apply it via category_encoders TargetEncoder with selected columns and a tunable smoothing parameter.
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.
- How it is used
- Transforms categorical features into model inputs using target-associated category statistics.
- 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.
Read how Machine Learning System Design explains mean target encoding →
What to know first
- gradient boostingGradient boosting is an ensemble-learning technique that sequentially adds predictive models fitted to reduce a loss by following its gradient.
- categorical dataCategorical data consists of values representing membership in discrete categories rather than measured numerical magnitudes.
- decision treeA decision tree is a tree-structured model or representation in which successive tests or choices lead through branches to outcomes, predictions, or actions.
- cross-validationCross-validation is a model-evaluation technique that repeatedly partitions available data into training and held-out subsets to estimate performance on unseen data.
Related concepts
- supervised encodingkind of · Supervised encoding is a categorical-feature encoding technique that uses target values when deriving category representations.
- target leakingproduces · Target leakage is the unintended use of information about a prediction target that would not be available when making predictions.
- TargetEncoderimplemented by · TargetEncoder is an encoding method that replaces categorical values with statistics computed from the target variable, often using smoothing.
- encodingkind of · Encoding is the process or scheme of mapping information into a different representation according to defined rules for storage, processing, transmission, or interpretation.
- labeluses · A label is a target value, category, or reference annotation associated with an example for learning, prediction, or evaluation.
- high-cardinality categorical featureaddresses · A high-cardinality categorical feature is a categorical feature with many distinct values relative to its dataset or analysis context.
Questions about mean target encoding
What is mean target encoding?
Mean target encoding is a categorical encoding technique that replaces each category with the mean of its associated target values.
Which Manning books explain mean target encoding?
Ensemble Methods for Machine Learning, Machine Learning for Tabular Data: XGBoost, Deep Learning, and AI and Machine Learning System Design.
What should I know before learning mean target encoding?
Manning books that teach mean target encoding usually introduce gradient boosting, categorical data, decision tree and cross-validation first.
What is mean target encoding a kind of?
Mean target encoding is a kind of supervised encoding. Supervised encoding is a categorical-feature encoding technique that uses target values when deriving category representations.
These guides are generated from the text of Manning books by Manning's knowledge graph and link to the sections they draw on. The full books are available on liveBook and at manning.com.


