ML data engineering
Identifiers, Keys, and Entity Resolution
Engineer stable identity across scopes, aliases, merges, uncertainty, and temporal change.
By the end you can
- Distinguish natural, surrogate, composite, scoped, and probabilistic identifiers
- Define entity sameness, namespace, and effective intervals
- Preserve uncertainty and evidence during entity resolution
- Version identity merges and splits for historical reproducibility
Example
Identity errors change labels and evaluation groups
Entity resolution fails in two directions. A false merge welds two subjects into one. A false split fragments one subject into many. The first has been counted.
ECRI Institute PSO collected wrong-patient reports for 32 months, from January 2013 through August 2015. It filtered 10,915 collected reports down to 7,613 wrong-patient events, submitted by 181 healthcare organisations, and coded 7,740 failure modes in them. Its August 2016 Deep Dive on patient identification reports that 91.4% were caught before harm reached the patient. The remainder is what an identity error costs.
One of the sample events reads: “A patient in cardiac arrest was mistakenly not resuscitated because the care team pulled up the wrong patient’s record and adhered to a do-not-resuscitate order.” The U.S. Government Accountability Office repeated the case independently in January 2019, citing ECRI's Deep Dive. A false merge is not a row-count anomaly. It is one record's instructions executed on another person.
- Shared contact: two family members use one phone number and are incorrectly merged into one customer profile, after which the merged profile carries both histories and neither person's is correct.
- Device reset: one physical device receives a new identifier and appears as a new machine after maintenance. Apple states that “If you erase all content and settings or reset network settings on your device, it uses a different private address the next time it joins the network.” The Android Open Source Project says of its randomized address that “This MAC address remains the same until a factory reset.”
- Account merge: historical transactions are reassigned to today’s surviving account without preserving the old mapping interval, so a question about last year is answered by an identity that did not exist then.
- Hashed email change: a normalization update changes the hash input and fragments one person into two identities — a false split that no uniqueness constraint will ever report.
- Household bridge: duplicate membership intervals create a many-to-many join that multiplies every household feature.
Visual
Keys identify different objects and scopes
A single identifier rarely serves every join safely. The loss from crossing a scope boundary has been measured with the identifier, the vendor and the organisation all held fixed. Kaiser Permanente runs 17 instances of Epic across its regions. A 2014 report for the Office of the National Coordinator for Health Information Technology records what that costs: “For example, Kaiser Permanente (which has 17 instances of Epic across its regions) reported a match rate of greater than 90 percent within each instance; that rate fell to around 50 percent to 60 percent when sharing between regions using a separate instance of Epic or with outside Epic partners.” Thirty to forty points of match rate disappear because the namespace changed, not because the patients did.
The same report looked at master patient indexes. Studies of 112 MPIs gave a mean duplication rate of eight percent, and 11 combined EMPIs ranged from seven to 39 percent duplication. The Government Accountability Office found the same order of magnitude in 2019: “A 2014 study found that as few as 50 percent of records are accurately matched when organizations exchange information”. Where a key is designed to survive cross-scope use, the scope is written into the standard instead of assumed. The Global Legal Entity Identifier Foundation states that “Every LEI is unique and can only ever represent one entity”.
Entity key
Identifies a persistent subject within a documented namespace and lifecycle.
Event key
Identifies one logical occurrence across retries or transport duplication.
Episode key
Groups related events into a session, visit, claim, trip, or case.
Composite example key
Combines entity, counterpart, and prediction time to identify one ML example.
Temporal mapping key
Links changing identifiers or attributes during a bounded validity interval.
Key validity has a namespace, scope, and time interval; uniqueness without scope is an incomplete claim.
Identity logic is a modeling decision disguised as plumbing
Joining tables decides which records describe the same subject, which events belong to one episode, and which context is attached to an example. Those are substantive assumptions about the world. SQL will happily execute a many-to-many join that multiplies rows. The result may contain valid-looking values, pass type checks, and still change the learning population dramatically.
Keys also have lifecycles. Accounts merge, devices reset, email addresses are shared, and external identifiers can be recycled. A field that is unique today may not be globally or historically stable. The gap is measurable rather than theoretical: the same organisation, the same EHR vendor and the same patients produce a match rate above 90 percent inside one Epic instance and around 50 to 60 percent across instances.
Building a dataset reliably begins by declaring key scope, join cardinality, temporal validity, and duplicate policy before computing features.
Every join should state what relationship it claims and how many output rows that relationship is allowed to create.
Key idea
Deduplication requires a definition of sameness
Dropping duplicate rows is not a general deduplication strategy. Two identical payloads may be legitimate repeated actions, while two different payloads may be retries of one logical event.
Use event IDs, source sequence numbers, transaction IDs, or domain-specific matching rules, and preserve the reason a record was removed and the competing records considered.
When exact identity is unavailable, probabilistic resolution should expose confidence and review thresholds. Hard merges create irreversible contamination if uncertainty is hidden.
Fellegi and Sunter formalised this in 1969: “These three decisions are referred to as link (A 1), a non-link (A 3), and a possible link (A 2)”. The third is not a failure. William Winkler's Census Bureau survey restates the rule with two cutoffs. Pairs between them are held “for clerical review”, and the cutoffs are “determined by a priori error bounds on false matches and false nonmatches”.
The U.S. Census Bureau runs that rule at national scale and publishes both error directions. The 2010 Decennial Census file arrived with 312,471,327 records delivered and no SSNs on them. Wagner and Layne reported in 2014 what happens next: “Because records for the 2010 Decennial Census lack SSNs, this file is sent to the probabilistic GeoSearch module and PIKS are assigned to 86 percent of the records”.
An outside assessment then measured the two errors separately. NORC at the University of Chicago tested the Bureau's Person Identification Validation System against a truth deck of CPS 2001 records whose SSNs had been verified: “A review of the validated records from search procedures showed that 0.34 percent were false-matches, that is, the search process assigned a different SSN than the verification process.” That rate was revised to 0.31 percent after clerical review. Beside it sits the other direction, “Of all the records in the truth deck, 2.0 percent were failed-matches”, with “about 90 – 93 percent of survey records are matched to the PVS reference files and assigned PIKs”. False merges and false splits are different numbers with different victims. A system that publishes only one of them is publishing half its behaviour.
Where the cutoffs sit has a price, and for one deployed matcher that price is on record. About one in 4,000 voters cast two ballots in the 2012 US presidential election. Goel and colleagues, writing in the American Political Science Review in 2020, then costed the obvious remedy: “For this subset of states, we find that one suggested strategy to reduce double voting—removing the registration with an earlier registration date when two share the same name and birthdate—could impede approximately 300 legitimate votes for each double vote prevented.” The Brennan Center for Justice reports the Interstate Crosscheck programme running at a “less than 3 percent accuracy rate in flagging double-votes”. Three hundred blocked legitimate votes for every double vote prevented is what a hard merge on name plus date of birth costs, once somebody writes the number down.
Deduplicate logical occurrences, not merely identical rows.
Analogy
Sorting a family archive into folders
Photographs, letters, and certificates have to be sorted into a folder for each person. Names may change, two people may share a name, and one document may refer to a household rather than an individual. Identifiers are clues. A canonical entity record is the folder, while temporal mappings explain which name or address applied during each period. Automated matching assigns probabilities at scale, with nobody free to hesitate over a single document. A false merge can contaminate many features and labels before anyone inspects the individual records.
Entity resolution should preserve uncertainty and mapping history instead of forcing every ambiguous record into one permanent identity.
Steps
A safe workflow for building the canonical table
Use assertions at every join boundary rather than checking only the final row count, and treat step 5 as a question about who is missing rather than how many.
Match failure is not spread evenly across people. A 2016 Census Bureau report by Joshua Comenetz counts the names: “About 6.3 million different surnames were reported by census respondents in 2010”, covering 295 million people, of which “3.9 million, or 61.9 percent, were reported only once”. Collision is where the groups separate. The ten most common surnames cover 4.9 percent of the total population, and it takes 239 surnames to reach a quarter of it. For the White alone population the figures are 4.5 percent and 319 surnames. For Black alone, 13.0 percent and 43. For Asian and NHPI alone, 13.4 percent and 41. And then: “The highest level of clustering is found in the Hispanic population, where just 26 surnames cover a quarter of the population and 16.3 percent of people reported one of the top 10 names.” A surname-based blocking key therefore collides far more often in one group than in another, before any algorithm has been chosen.
The Brennan Center for Justice describes the consequence in a deployed system: “It often flagged false positive matches because it relied on a combination of name matches, which inaccurately picked out common names, and date of birth matches, which were frequently missing or inaccurately entered into state systems”.
A single reconciliation figure hides all of that. The Census Bureau's 86 percent assignment rate on the 2010 Decennial file is where step 5 begins, not where it ends. The question is which slices make up the remaining fourteen percent, and whether they are the same slices next month.
1. Declare both grains
Write what one row represents on the left and right sides.
2. Profile key multiplicity
Measure nulls, duplicates, match rates, and records per key on each side.
3. State expected cardinality
Choose one-to-one, many-to-one, one-to-many, or intentional many-to-many.
4. Join with temporal rules
Use validity intervals or as-of logic when attributes change over time.
5. Reconcile the output
Check row multiplication, unmatched records, aggregate conservation, and slice effects.
A join is complete only after its cardinality, match behavior, and population effects have been reconciled.
Key idea
Identifiers can be recycled, reassigned, and scoped
A device serial may be reused after repair, an email address can change owner, and an account ID can be unique only inside one tenant. Treating such keys as timeless global identity merges unrelated histories. Record namespace, validity interval, source authority, and confidence. For probabilistic matches, preserve candidate evidence and avoid forcing one canonical identity when uncertainty matters.
Reassignment has a national rate and a regulator. The Federal Communications Commission put the rate in its December 2018 order on unlawful robocalls: “Approximately 35 million numbers are disconnected and made available for reassignment to new consumers each year”. The Commission's answer was a national Reassigned Numbers Database and a validity gap written into the rules: “We establish a minimum aging period of 45 days, in the middle of the proposed range, for all numbers”. The Federal Register text, effective 26 March 2019, records that the Commission “sets a minimum aging period of 45 days before a permanently disconnected number may be reassigned to a new subscriber”. The database, run by SomosGov, became generally available on 1 November 2021. Join on a phone number without a validity interval and you have inherited whatever the previous subscriber did.
Device identifiers move in the other direction: unstable by design, and scoped on purpose. Apple documents that “By default, your device improves privacy by using a different MAC address for each Wi-Fi network. This unique MAC address is your device's private Wi-Fi address, which it uses for that network only”, and that “When set to Rotating, your device uses a private address that rotates to a different private address every 2 weeks”. The Android Open Source Project documents the same design independently: “For devices running Android 10 or higher, the framework uses a randomized MAC address by default”. One device, a different key per network scope, and a fresh key after a reset. The platform vendors have published the false split in advance.
Identifier formats now carry time inside them. RFC 9562, published in May 2024, obsoleted RFC 4122 and added version 7. Its value field comes from “the widely implemented and well-known Unix Epoch timestamp source, the number of milliseconds since midnight 1 Jan 1970 UTC”. PostgreSQL 18 ships uuidv7() and documents a “48-bit millisecond timestamp field”. A sortable key is convenient. It also publishes when the row was created.
A unique value is not necessarily a permanent identity.
Identity decisions need version history
Entity resolution changes as new evidence arrives. A merge made today should not silently rewrite which records were linked at an earlier scoring cutoff.
Version merges, splits, aliases, and confidence so historical datasets can reconstruct the identity graph available at the time, and monitor the model impact of large reconciliation changes.
The Financial Stability Board wrote that contract into a live global scheme. Its 8 June 2012 report to the G20 sets out 35 recommendations for a global Legal Entity Identifier. One of them fixes uniqueness: “only one LEI may be assigned to any financial market counterparty”. Another fixes the shape of the key, against the standard ISO 17442:2012, dated 30 May 2012: “The technical code of the LEI should be a 20 digit alpha numeric number as set out in the ISO standard 17442:2012. The code should not incorporate any intentional embedded intelligence (such as a country reference) which would lead to the code becoming out of date.” A surrogate key, one issuing authority, and no meaning buried inside the string.
The temporal half of the contract comes in a footnote: “For entities with a date of expiry, the reason for the expiry should be recorded, and, if applicable, the LEI of the entity or entities that acquired the expired entity.” An expiry date, a reason, and a pointer to the successor is precisely the record a merge should leave behind. The old identity is not overwritten. It is closed and linked, so a dataset built last year can still be reconstructed. The Global Legal Entity Identifier Foundation, which now operates the Global LEI System, describes the resulting code as “a unique 20-character alphanumeric code that enables anyone, anywhere in the world, to access clear, unique identification data about a legal entity”.
The identity graph is a dataset with its own temporal contract.
Key takeaways
- Joins encode assumptions about identity, relationships, time, and population, not merely table mechanics.
- Keys need a documented namespace, scope, lifecycle, and temporal validity as well as uniqueness: the same vendor and the same organisation kept a match rate above 90 percent inside one Epic instance and 50 to 60 percent across instances.
- Join cardinality should be declared before execution and reconciled afterward with row and key-level evidence.
- One-to-many and many-to-many joins can duplicate labels or change sampling weights unless expansion is intentional.
- Entity resolution must manage both false merges and false splits and report them separately, as the Census Bureau's PVS does at 0.31 percent false matches against 2.0 percent failed matches.
- Reconciliation should explain matched, unmatched, duplicated, filtered, and multiplied records by slice — surname collision alone runs from 4.5 percent to 16.3 percent between groups.