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 →
Related concepts
- TargetEncoderimplemented by · TargetEncoder is an encoding method that replaces categorical values with statistics computed from the target variable, often using smoothing.
- target leakingproduces · Target leakage is the inclusion or use of information derived from the prediction target that would be unavailable when making predictions.
- supervised encodingkind of · Supervised encoding is a categorical-feature encoding technique that uses target values when deriving category representations.
- labeluses · A label is a value or annotation associated with an item that identifies its target category, outcome, or reference answer for learning or evaluation.
- embeddingalternative to · A numerical vector representation of an item or input that encodes features or relationships useful for computational tasks.
- high-cardinality categorical featureaddresses · A high-cardinality categorical feature is a categorical feature with many distinct values relative to its dataset or analysis context.
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.


