liveBook · Manning

N-gram

As explained in Ensemble Methods for Machine Learning

An n-gram is a contiguous sequence of n successive tokens, such as characters or words, extracted from a string.

When strings are too long for convenient character-by-character comparison, break them into smaller pieces. An n-gram is a contiguous sequence of n successive tokens, such as characters, substrings, or words. section 8.4

The value of an n-gram comes from comparison: token-based string-similarity methods compare overlapping pieces of longer strings, helping group similar high-cardinality categories or clean noisy spellings. section 8.4

Employee titles

A salary model can encode many employee-position titles by comparing their substring patterns instead of treating every title as unrelated. MinHashEncoder and GapEncoder provide production encoders based on substrings or frequently co-occurring substring combinations. section 8.4

How Ensemble Methods for Machine Learning covers it

How deep it goes
Defines n-grams and places them in token-level similarity, without detailing extraction or comparison algorithms.
Examples
Uses employee-position titles, substring patterns, MinHashEncoder, and GapEncoder as practical examples.
What it assumes
Assumes familiarity with strings and categorical features while defining token-level decomposition directly.
What you can do after
Apply n-gram-based similarity through specialized encoders for noisy or high-cardinality string categories.
How it connects
Connects n-grams with string similarity, character-based similarity, token-based similarity, high-cardinality features, and dirty categories.

Also explained in

Compare how 4 books explain n-gram →

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.