liveBook · Manning

Character-based string similarity

As explained in Ensemble Methods for Machine Learning

Character-based string similarity compares strings according to character-level operations such as insertion, deletion, and substitution.

Character-based string similarity compares strings by counting character-level operations—insertions, deletions, and substitutions—needed to transform one string into another. Higher similarity scores indicate closer matches. The approach suits short strings, while longer strings are often compared as tokens or n-grams. section 8.4

This comparison is useful when categories contain typos or many distinct values: similar strings can be grouped or converted into numerical features instead of receiving unrelated categorical codes. section 8.4

A practical workflow is:

  • Choose character-level similarity for short categorical strings; consider token-based methods for longer strings. section 8.4
  • Encode noisy or high-cardinality categories with dirty_cat, using SimilarityEncoder or related substring-based encoders. section 8.4
  • Evaluate the encoded features inside a modeling pipeline rather than assuming similarity improves every model. section 8.4

Employee salary categories

A salary dataset contains 385 employee position titles. A pipeline compares SimilarityEncoder, MinHashEncoder, and GapEncoder alongside low-cardinality and continuous features; reported R² scores are 0.8996, 0.8997, and 0.8895 respectively. section 8.4

How Ensemble Methods for Machine Learning covers it

How deep it goes
Defines character operations and tradeoffs, then stops short of deriving a specific similarity algorithm.
Examples
Uses employee position titles, dirty_cat encoders, a salary pipeline, and reported R² comparisons.
What you can do after
Apply it via dirty_cat encoders to represent noisy or high-cardinality categorical features.
How it connects
Connects character-based similarity with token-based similarity, n-grams, categorical encoding, and dirty categories.

Related concepts

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.