Skip to content

Add worked example: encoding dirty categories with the GapEncoder#1939

Open
Fazel94 wants to merge 2 commits into
online-ml:mainfrom
Fazel94:gap-encoder-example
Open

Add worked example: encoding dirty categories with the GapEncoder#1939
Fazel94 wants to merge 2 commits into
online-ml:mainfrom
Fazel94:gap-encoder-example

Conversation

@Fazel94

@Fazel94 Fazel94 commented Jul 2, 2026

Copy link
Copy Markdown
Contributor

A worked example notebook for the GapEncoder (see #1439), living under docs/examples.

It builds a stream of hand-typed city names — 689 spellings for only 9 real cities — where the label depends on the true city but the model only sees the misspelled version. One-hot encoding barely beats chance (57% ROC AUC) because every typo is a new, unrelated category, while the GapEncoder recovers almost all the signal (70%, right next to a 72% oracle that gets to see the clean names). The notebook also shows fuzzy variants clustering by cosine similarity and the labels the topics learn.

Stacked on #1938 (which adds the GapEncoder itself) — this PR should be merged after it. Until then the diff shows both changes; it'll narrow to just the notebook + nav once #1938 lands.

Fazel94 added 2 commits July 3, 2026 00:40
Online Gamma-Poisson factorization of character n-gram counts, for
encoding messy string categories (hand-typed city names, and the like).
It's the one-at-a-time version of skrub's GapEncoder: the n-gram
vocabulary and the topics both grow as strings arrive, topic updates use
A/B accumulators with a rho forgetting factor, and transform_one is
read-only. Passes check_estimator.

Closes online-ml#1439
A runnable notebook under docs/examples that shows where the GapEncoder
pays off: a stream of hand-typed city names (689 spellings for 9 real
cities) where one-hot barely beats chance (57% ROC AUC) while the
GapEncoder recovers almost all the signal (70%, next to the 72% oracle
that sees the clean names). Also shows fuzzy variants clustering and the
learned per-topic labels. Registered in the docs nav.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant