KatInterview

Finding Duplicate Transactions in a Payment Dataset

Machine LearningModel answer
MediumModel answerMachine Learningrecord-linkagedata-qualityentity-resolution

Last updated

Design a system to detect, classify, and quantify duplicate records in a payment transaction dataset, handling both exact matches and fuzzy near-duplicates.

You are working with a large payment transaction dataset and notice that some records may represent the same underlying event more than once.

Address the following:

Part 1 — Root causes What real-world scenarios produce records that look like duplicates? Group them by cause: pipeline behavior, transaction lifecycle, and legitimate repetition. For each group, explain why the distinction matters downstream.

Part 2 — Defining "duplicate" What makes two records the same transaction versus two genuinely separate transactions? Define a precise, operational criterion. Account for cases where two records differ in small ways — different formatting, mismatched timestamps, slight merchant name variations — but may still represent a single event.

Part 3 — Detection and quantification Describe a practical pipeline for finding duplicates at scale. Cover:

  • How to normalize records before comparison
  • How to avoid O(n²) pairwise comparison
  • How to score candidate pairs and decide whether they match
  • How to measure the duplicate rate in a meaningful way — not just row counts, but in terms of business impact

Your answer should be structured and concrete. Mention the trade-offs in any choices you make, and identify at least one common mistake candidates make when approaching this problem.

Hints

Hint 1

Before jumping to code, ask what 'same transaction' means in the context of the business. An authorization and its settlement share the same purchase but should not be merged — they serve different analytical purposes.

Hint 2

Pairwise comparison across all records won't scale. Think about what fields you can use as a blocking key to restrict comparisons to a small, high-recall candidate set before scoring.

Hint 3

A raw row-level duplicate rate can be misleading. Consider weighting by transaction amount — a 1% row duplication rate concentrated on large transactions can inflate reported spend by 5% or more.