Blog
Text similarity for fraud detection: string metrics, pattern matchers and decision models
Edit distance, Jaro-Winkler, token, phonetic and pattern methods for fraud checks, tested on email versus name, plus what a decision model added on the same facts.
· 6 min read
Why text similarity matters in fraud
A surprising number of fraud signals are comparisons between two strings somebody typed. The email against the name on the order. The cardholder name against the account holder. A shop name one letter away from a well-known brand, or a sign-up domain registered to look like a bank's. Two accounts whose addresses differ only in the flat number's format.
Every one of these comparisons can fail in two directions. Make it strict and you flag the customer who signs up as bob.doe when the card says Robert Doe. Make it loose and a mailbox that merely shares some letters with the name passes as a match. The second failure is the expensive one, because nobody complains about it.
The main families of methods
Edit distance (Levenshtein) counts the single-character edits between two strings. It is cheap and catches typos. It has no idea that Bob and Robert are the same person.
Jaro-Winkler counts shared characters inside a window and adds a bonus for a shared prefix. Winkler built it for record linkage, where you compare two spellings of the same surname, and it is very good at that job. Point it at a mailbox name and it will reward any string assembled from the same letters as the name.
Token and set methods such as Jaccard and SoftTFIDF split text into words and compare the sets, so word order stops mattering. For emails the catch is simple: johnsmith is one token.
Character n-grams work well on lookalike domains and merchant names. On a five-letter mailbox there is not much to compare.
Phonetic codes like Soundex group names that sound alike. Handy for surnames, and tied to English pronunciation.
Rule-based matchers write down how people actually build the text. They are fast, and an analyst can read why they matched. Someone has to maintain the rules and the nickname table, and that someone is you.
Trained models and embeddings learn similarity from labelled pairs. If you have the labels and the latency budget, they can be worth it. Most fraud teams have neither for this question, and an embedding distance is hard to explain to an analyst.
A worked example: is the email built from the name
Take an invented customer, John Doe, signing up with [email protected]. Show that pair to a reviewer and they will tell you the mailbox has nothing to do with the name.
A typical fuzzy score disagrees. Compare jdeo with jdoe, the first initial plus the surname, and Jaro-Winkler finds the same letters in almost the same order, starting with the same two. The score lands above the thresholds people usually pick, and the pair goes through as a match.
Tuning will not fix it. Jaro-Winkler measures whether two strings share letters, and that is a different question from whether one was built from the other. Raise the threshold far enough to reject jdeo and you start rejecting real customers whose mailbox is their name plus a hobby. The same score also knows nothing about nicknames, so bob.doe does badly for Robert Doe.
A pattern matcher instead of a score
So we stopped asking how similar the strings are and started asking which parts of the mailbox come from the name. Our matcher looks for whole names, nicknames from a reviewed nickname table, short forms, typos and initials. In jdeo it finds none of them, and the answer is unrelated.
The output is a pattern rather than a number: full name, first name plus initial, one name only, initials, unrelated and a few others. It also reports how much of the mailbox the name explains, and a plain match flag. A rule such as email not similar to name reads the pattern. There is no model and no network call, and it runs in microseconds. That matters inside every scoring request.
We tested it on synthetic pairs with invented names and on a smaller set of pairs we labelled by hand. Treat the synthetic set with suspicion: we wrote both the generator and the matcher, so mostly it confirms the matcher does what we designed it to do. The hand-written set is the honest test, and it is small. On both, the matcher caught lookalikes the fuzzy score let through and accepted nicknames the fuzzy score rejected. It still makes mistakes, and a reviewer will catch some pairs it gets wrong.
Two methods from the research, tried and set aside
Before trusting our own design, we built two published methods beside it. One used the longest-common-subsequence word similarity from Gahman and Elangovan's comparison of document similarity algorithms. The other used SoftTFIDF over Jaro-Winkler, one of the stronger lexical methods in the study by Prasetya, Wibawa and Hirashima.
Neither came close. We tuned their thresholds on the synthetic set, ran them unchanged on the hand-written pairs, and both lost to the matcher on both. They read johnsmith as one word and they have no notion of a nickname. We deleted them.
What a decision model adds
Next we tested whether a decision model would do better. We tried more than one. None of them saw the name or the email. Each got a handful of facts our code had computed, such as the pattern and how much of the mailbox the name explains, and answered closed questions about them in one request.
Given the pattern, the models agreed with it. They also made the same mistakes as the matcher on the hand-written pairs, which is what you would expect: a model that never sees the letters cannot judge the letters. Without the pattern they gave a noisier reading of the same facts.
Speed and price separated the models more than the quality of their answers did. A fixed model version mattered too: a threshold you tune today should mean the same thing next month, and we would hesitate to tune anything against a model whose version can change without notice.
What improved the model answers
Small changes to the request made a real difference. We sent only the facts each question needed, and we wrote the answer criteria in plain terms tied to those facts. After these changes the answers were more consistent and the probabilities were better calibrated.
One lesson we would pass on: if a question cannot be answered for a given customer, do not ask it. A yes or no question has no way to say not applicable.
When to use which
If the question is about the letters themselves, use a deterministic matcher. You can write down how people build mailboxes, it costs next to nothing to run, and the personal data never has to leave memory.
A decision model earns its place one level up, where the matcher's result meets the rest of the event, such as a free webmail domain or an account created an hour ago. Give it one plain fact from the matcher, never the strings. Run it in shadow first and keep it advisory. We would not let a model's answer about a single fact switch a rule on or off.
Limits of this test
The pairs are synthetic or hand-written, every name is invented, and the hand-written set is small. Model timings and prices vary by provider and over time, so yours will differ. Some names cannot be compared yet.
How FRAPE uses this
The matcher runs inside scoring and gives your rules three email fields: the pattern, the share of the mailbox the name explains and the match flag. A rule such as email not similar to name reads the pattern and adds its points. Decision Core receives only a description of the pattern, never the name or the email, and your policy makes the decision.
Sources
- Winkler: String Comparator Metrics and Enhanced Decision Rules in the Fellegi-Sunter Model of Record Linkage (1990, ERIC ED325505)
- Gahman and Elangovan: A Comparison of Document Similarity Algorithms (arXiv, April 2023)
- Prasetya, Wibawa and Hirashima: The performance of text similarity algorithms (International Journal of Advances in Intelligent Informatics, vol. 4, no. 1, 2018)