liveBook · Manning

MinHashEncoder

As explained in Ensemble Methods for Machine Learning

MinHashEncoder is a dirty_cat transformer that represents categorical strings using hashing applied to their substrings.

MinHashEncoder turns categorical strings into compact numeric features by hashing their substrings. This helps models handle many distinct values and noisy categories without creating one column per category. section 8.4

Use it when categorical values are numerous or imperfect:

  • Represent high-cardinality categories with a chosen encoding dimension instead of expanding every category into a separate one-hot column. section 8.4
  • Compare it with SimilarityEncoder, which uses string similarity, and GapEncoder, which uses frequently co-occurring substring combinations. section 8.4

Employee salary prediction

A salary dataset contains 385 unique employee position titles. MinHashEncoder(n_components=100) can encode that high-cardinality column before an XGBoost regression model is trained in a scikit-learn pipeline. In one comparison, it achieved an R² score of 0.8996750692009536. section 8.4

How Ensemble Methods for Machine Learning covers it

How deep it goes
Defines substring hashing and encoding dimension, but does not detail the hashing procedure or collision behavior.
Examples
Uses employee position titles with 385 categories, a 100-component encoder, and salary regression evaluation.
What it assumes
Assumes familiarity with categorical features, one-hot encoding, regression, and scikit-learn pipelines.
What you can do after
Apply it via dirty_cat in a scikit-learn pipeline for high-cardinality categorical features.
How it connects
Connects categorical encoding with SimilarityEncoder, GapEncoder, one-hot encoding, scikit-learn pipelines, and XGBoost.

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