Splink for Deduplication in BI Data Projects

Splink for Deduplication in BI Data Projects

The Reality of Business Intelligence Projects

Anyone who’s ever done a BI project knows the pattern: you’ve got a business requirement and need a BI solution. First, you agree on the requirements, design the architecture or data model, and sketch out the dashboards. Then the first extract of real data arrives: names are in capitals in one system and in lowercase in another, dates of birth are stored as text, and Spanish national ID numbers (DNI) have hyphens in some systems but not in others; a mandatory field is left blank, and postcodes have all sorts of odd characters in them…

 

Before anyone even looks at a KPI, a huge amount of effort has gone into data quality (profiling, cleansing, standardising, and validating). Of all these issues, duplicate records deserve special mention: they’re not an anomaly, but a result of the way organisations collect data about the same person at different times and in different systems.

 

For instance, in the insurance sector, the same customer may appear in policy, claims, and CRM systems with different names, outdated addresses, or missing identifiers. Deduplication helps link these records into a consistent customer view, improving BI reporting and analysis of policy ownership and claims history. Here are some of the common issues we face:

  • Multiple source systems: Policy, claims, and CRM systems each keep their own records for the same customer.
  • Changes over time: Someone can buy a car policy through an agent or through their home insurance policy, then report a claim by phone after moving house or changing their phone number.
  • Manual data entry: Typos in first names and surnames, nicknames or abbreviations, and empty fields are unavoidable when people enter data.
  • Incomplete identifiers: A national ID number (DNI) could solve most of the problems, but it is often optional, missing, or mistyped in secondary systems.
  • Migrations and acquisitions: Portfolios migrated from legacy platforms bring their own particular records of existing customers, making accurate reporting difficult.

 

Duplicates inflate the customer count and distort KPIs such as retention, cross-selling ratio, or customer lifetime value. This incorrect data could also lead to an increase in operating costs and hinder business decisions. The classic solution is deterministic matching: “two records refer to the same person if the ID number matches” or “if first name, surname, and date of birth are the same”. These rules are easy to understand, but a single typo can prevent a match, and if you loosen them too much, you’ll soon get false matches.

 

This is exactly where Splink can help! In this post we’ll show you a number of different scenarios to illustrate what Splink is and how it can manage complex deduplication processes.

 

 

The Project: A Single Customer View

 

To create a deduplication pipeline to bring together personal data from different source systems and identify which records belong to the same real-world individual, we combined two components (Figure 1 below):

  • Snowflake stores and standardises the source records. It also stores the pairwise match scores and cluster IDs so that other parts of the platform can query them using SQL.
  • Amazon SageMaker trains, runs, and inspects the Splink model. The pipeline reads the cleansed records from Snowflake and writes the results back.

 

Figure 1: High-level architecture of the deduplication pipeline

Figure 1: High-level architecture of the deduplication pipeline

 

 

Introducing Splink

 

Splink is an open-source Python library for probabilistic record linkage (also known as entity resolution).

  • It implements the Fellegi-Sunter model, a well-established statistical framework, and it can be trained without labelled data. There is no need for a manually curated set of known duplicates.
  • It is explainable: every match score can be broken down into the contribution of each field, which is essential when business users have to trust the result.
  • It runs on several SQL back-ends (DuckDB, Apache Spark, Amazon Athena, PostgreSQL, etc.), so the same model definition scales from a notebook to millions of records.

 

Conceptually, Splink works in five steps:

 

Figure 2: Splink deduplication model

Figure 2: Splink deduplication model

 

Blocking Rules

Deduplication means comparing records in pairs, and the number of pairs grows quadratically. For instance, 10,334 records can produce approximately 53.4 million possible pairs; a table with one million customers would produce around 500 billion. Comparing all of them is neither feasible nor necessary, because almost all of them refer to different people.

 

Blocking rules define which pairs are worth comparing. A pair is generated when it satisfies at least one rule, typically exact equality in one or several fields. Rules are combined with OR, so a duplicate that fails one rule (for example, because its ID is missing) can still be caught by another one (same date of birth and surname):

 

from splink import SettingsCreator, block_on

settings = SettingsCreator(
    link_type="dedupe_only",
    blocking_rules_to_generate_predictions=[
        block_on("doc_id"),
        block_on("dob", "surname_1"),
        block_on("first_name", "surname_1"),
        block_on("phone"),
        block_on("email"),
        block_on("postcode", "dob"),
    ],
    comparisons=[...],   # see next section
)

 

Selecting blocking rules is a balancing act: if they’re too strict, some genuine duplicate pairs will never be scored, reducing recall; if they’re too loose, you’ll generate far too many pairs and take far too long.

 

Comparisons

For each candidate pair, Splink looks at several comparisons (typically one per field). Each comparison has several levels (0, 1, 2, 3, 4, …) representing different degrees of agreement. A first name comparison would, for example, have levels which distinguish between:

  • An exact match (“carmen” vs “carmen”).
  • A very close match, measured according to jaro-winkler similarity (“carrmen” vs “carmen”).
  • A weaker fuzzy match.
  • Anything else (“carmen” vs “maria”).
  • A null level when either value is missing, so the field contributes no evidence for or against a match.

 

You can also define custom comparison logic for specific cases.

 

The predictions table shows all the fields with their gamma levels (0, 1, 2, 3, …), indicating which comparison level Splink selected for each field, alongside the associated score.

 

The final match weight is the sum of the prior match weight and all field weights, and it converts directly into a match probability between 0 and 1:

 

import splink.comparison_library as cl

comparisons = [
    cl.NameComparison("first_name").configure(term_frequency_adjustments=True),
    cl.NameComparison("surname_1").configure(term_frequency_adjustments=True),
    cl.NameComparison("surname_2").configure(term_frequency_adjustments=True),
    cl.DateOfBirthComparison("dob", input_is_string=True),
    cl.LevenshteinAtThresholds("doc_id", [1]),   # tolerate one typo in the ID
    cl.ExactMatch("phone"),
    cl.ExactMatch("email"),
    cl.ExactMatch("postcode").configure(term_frequency_adjustments=True),
]

 

The model parameters are estimated from the data itself. For each comparison level, Splink estimates two probabilities:

  • The m value is the probability of observing the same comparison result when two records refer to the same entity. For example, the m value for an exact date-of-birth match represents how often genuine duplicates have identical dates of birth. It may be less than 1 because of missing values or data-entry errors.
  • The u value is the probability of observing the same comparison result when two records refer to different entities. It captures how likely an agreement is to occur by chance. For example, unrelated people are more likely to share a common surname than an uncommon one.

 

The ratio m/u determines how much evidence a comparison result provides in favour of a match: a result with a high m value and a low u value provides strong evidence that the records represent the same entity.

 

The main idea behind expectation-maximisation (EM) training is to let the Splink algorithm learn which conditions or test cases are relevant to the matching decision:

 

from splink import DuckDBAPI, Linker

linker = Linker(df_clean, settings, DuckDBAPI())

linker.training.estimate_probability_two_random_records_match(
    [block_on("doc_id"), block_on("first_name", "surname_1", "dob")], recall=0.7)
linker.training.estimate_u_using_random_sampling(max_pairs=2e6)
linker.training.estimate_parameters_using_expectation_maximisation(block_on("dob"))
linker.training.estimate_parameters_using_expectation_maximisation(
    block_on("first_name", "surname_1"))

predictions = linker.inference.predict(threshold_match_probability=0.01)

 

Thresholds

Splink returns a probability for every candidate pair: pairs at or above the threshold are treated as matches, and changing it affects:

  • Precision: Of the pairs we link, what proportion refer to the same person? Low precision means linking different people.
  • Recall: Of all the real duplicate pairs, what proportion do we find? Low recall means duplicates remain in the data.

 

There is no universal threshold value. A common practice is to define two cut-off points: pairs at or above the upper cut-off are linked automatically, whilst pairs between the two are sent for manual review, and pairs below the lower cut-off are left unlinked.

 

Match probabilities range from 0 to 1. The closer the probability is to 1, the more likely it is that the two records refer to the same person. In our test case, we used a threshold of 0.95, but a pair with a probability of 0.89 could still be a genuine match.

 

Clustering

In this step, Splink uses the pairs that meet the match threshold to group records into clusters. If A matches B and B matches C, then A, B, and C all receive the same person identifier, even if A and C have never been compared. Splink does this through connected components clustering, where each group of linked records forms a cluster intended to represent one person. The output assigns a cluster_id to every record. The clustering depends on the blocking rules that were defined at the beginning of the process and the chosen match threshold:

 

clusters = linker.clustering.cluster_pairwise_predictions_at_threshold(
    predictions, threshold_match_probability=0.95)

 

Clustering is powerful because it can link records that were never compared directly, but it carries a risk known as chaining: a single wrong link can act as a bridge between two clusters belonging to different people, causing them to merge.

 

Visualising and Validating the Model

Splink includes a set of interactive charts, built on Altair/Vega-Lite, that can be generated directly from the SageMaker notebooks:

  • Match weights chart: Shows the weight of every comparison level and helps to identify parameters that don’t make business sense (Figure 3).
  • m and u parameters chart: The underlying probabilities for each level.
  • Waterfall chart: Explains a single prediction field by field (Figures 4 and 5).
  • Unlinkables chart: How many records lack enough information to ever reach a confident match.
  • Comparison viewer dashboard: An interactive HTML page to browse example pairs for every combination of comparison levels.
  • Cluster studio dashboard: An interactive HTML page that draws each cluster as a network of records and links, ideal for detecting chaining problems.
  • Custom charts: You can build your own charts based on the extract of the data generated by Splink.

 

Test Case: Deduplication in Multiple Data Sources

 

We tested the pipeline on synthetic insurance records from three source systems to see how well it identified duplicates, showing how Splink can help to create a unified customer view.

 

The Dataset

 

We generated 10,334 synthetic records representing 5,600 fictitious Spanish people across three source systems (policy administration, claims, and CRM). The dataset contained 6,768 genuine duplicate pairs. Each record contains a first name, two surnames, the date of birth, the national ID number (DNI), phone number, email, and postcode.

 

We also added some typical errors that are often found in data quality analysis:

  • Typos and transposed letters in names (12–15% of records), inconsistent capitalisation, and missing accents.
  • Spanish nicknames such as Pepe (for José) or Paco (for Francisco); first name and surname swapped around (5%).
  • Missing values in IDs, emails, second surnames, phone numbers, and dates of birth.
  • Inconsistent formats (for example, the ID with or without hyphens between the numbers and letters, phone numbers with or without the +34 prefix) and dates with the day and month reversed.
  • Changes to phone numbers, email addresses, and postal addresses.
  • We also included 600 relatives of existing customers as hard negatives. These relatives share surnames, a postcode, a landline, and sometimes an email with the customer. Some unrelated people also happen to have the same name (María García, José Martínez, etc.).

 

Table 1 shows a typical pair of raw records for the same person, coming from two different systems.

 

Source First name Surnames Date of birth ID (DNI) Phone number Postcode
CRM CARRMEN Soriano Pol 1967-10-25 95975272K 644179908 38954
CLAIMS Carmen Soriano Pol 1967-10-25 (empty) 644179908 38954

 

Table 1: Two raw records of the same (fictitious) person: a typo, different casing, and a missing ID

 

Cleansing: Snowflake Functions

 

We used Snowflake functions and procedures to standardise the records before loading them into Splink. The logic is simple, but its impact is significant. Typical cleansing operations include:

  • Removing accents and standardising capitalisation.
  • Cleaning and normalising addresses, IDs, multi-word town and city names, and special characters like hyphens and commas.
  • Normalising phone numbers and other fields.

 

import re, unicodedata

def norm_text(s):          # "Fernández " -> "fernandez"
    s = unicodedata.normalize("NFKD", s).encode("ascii", "ignore").decode()
    return re.sub(r"[^a-z ]", "", s.lower()).strip() or None

def norm_doc(s):           # "71012928-z" -> "71012928Z"
    return re.sub(r"[^0-9A-Z]", "", s.upper()) or None

def norm_phone(s):         # "+34 654 544 651" -> "654544651"
    digits = re.sub(r"\D", "", s)
    return digits[-9:] if len(digits) >= 9 else None

 

Cleansing in itself makes a difference, so it’s an important improvement for our dataset even without using Splink.

 

Training and Inspecting the Model

After completing the training, the first thing to consider is the weights chart (Figure 3). Each component must have business logic behind it:

  • The prior match weight is −13.1: the probability of two random records being from the same person before any comparison is approximately 1 in 9,000.
  • Exact matches of date of birth, national ID, phone number, email, and postcode will give between +12.3 and +13, the strongest points in the model.
  • An exact name match contributes between +6.4 and +7.4, whilst fuzzier matches receive lower weights; term frequency will subsequently reward rare names and penalise frequent ones.
  • A date of birth that is off by more than a year brings −17, meaning that it’s strong evidence against matching.
  • Different national IDs only lower the points by 5.6, which is less than expected due to possible typos in some IDs in different systems.
  • A different second surname will give −45 in an extreme case.

 

Figure 3: Splink match weights chart for the trained model

Figure 3: Splink match weights chart for the trained model

 

Results

We scored all candidate pairs and compared the predictions with the ground truth at different thresholds (Table 2):

 

Threshold Pairs linked Correct Wrong Precision Recall
0.50 6,367 6,324 43 99.32% 93.44%
0.80 6,334 6,299 35 99.45% 93.07%
0.90 6,282 6,250 32 99.49% 92.35%
0.95 6,223 6,195 28 99.55% 91.53%
0.99 6,180 6,160 20 99.68% 91.02%
0.999 6,065 6,050 15 99.75% 89.39%

 

Table 2: Pair-level results at different match probability thresholds (6,768 true duplicate pairs)

 

At the chosen threshold of 0.95, the model finds 6,195 of the 6,768 duplicate pairs (91.5% recall) with only 28 wrong links (99.55% precision). Table 3 puts this in context against deterministic rules:

 

Approach Duplicate pairs found Recall Precision
Exact DNI, raw data 1,576 23.3% 100%
Exact first name + surname + DOB, raw data 1,378 20.4% 100%
Exact DNI, cleansed data 2,682 39.6% 100%
Exact first name + surname + DOB, cleansed data 2,418 35.7% 100%
Splink, probability ≥ 0.95 6,195 91.5% 99.55%

 

Table 3: Splink vs deterministic matching rules on the same dataset

 

After clustering, the 10,334 records collapse into 5,811 person identifiers, compared with 5,600 individuals in the dataset: this is a 44% reduction from the original record count. 99.66% of the clusters are pure (all their records belong to the same person), and only 20 clusters mix two different people.

 

Explaining Individual Decisions

Figure 4 below shows how Splink scored the two records from Table 1. The date of birth, postcode, and phone number match exactly, providing strong evidence that the records refer to the same person. Both surnames also match. Although the first name contains a typo, Splink still gives “CARRMEN” and “Carmen” a positive score as a fuzzy match.

 

If we had only applied a deterministic rule for the DNI, we would have missed the match as this value is empty in the CLAIMS data source.

Figure 4: Waterfall chart of a correctly detected duplicate

Figure 4: Waterfall chart of a correctly detected duplicate

 

Where the Model Gets it Wrong

We must also check why Splink is generating false positives and validate the different combinations. Let’s look at this example shown in the table below.

 

Malena and José Luis Palmer Anaya are relatives with the same first and second surnames, the same postcode, and the same phone number. Their different first names and dates of birth subtract around 20 points, but the shared surnames, phone number, and postcode add more than enough to overcome that, ending in a weight of 8.25 (a probability of about 99.7%). The national ID number, which would have settled the question, is missing in one of the records:

 

Source First name Surnames Date of birth ID (DNI) Phone number Postcode
CRM Malena Palmer Anaya 1987-02-25 (empty) 672234675 24047
CLAIMS Jose Luis Palmer Anaya 1960-10-05 88248308E 672113864 24047

 

Table 4: Two records belonging to different members of the same family

 

This is a typical failure in insurance data: households share addresses and contact details, whilst individual identifiers are frequently missing. Possible mitigations include term-frequency adjustments on email addresses and phone numbers (so that contact data shared by several people counts for less), a post-processing rule that requires a minimum agreement on first names or dates of birth, or sending these cases for manual review.

 

Figure 5: Waterfall chart of a false positive between two relatives

Figure 5: Waterfall chart of a false positive between two relatives

 

 

Splink Data Deduplication: Key Points

 

In BI projects, duplicates are inevitable, the natural outcome of having multiple systems and many years of history all describing the same customer. In this test case, we used Snowflake as our cleansing platform as well as our central data platform. Splink running on Amazon SageMaker enabled us to move from a fragile set of exact-match rules to an explainable, probabilistic model of who is who.

 

What did we learn?

  • Cleanse first: Standardising text, IDs, and phone numbers is inexpensive and can almost double the number of duplicates found by exact matching.
  • Exact rules are not enough: Even after cleansing, deterministic matching found at most 40% of the duplicates, whereas Splink found 91.5% with 99.55% precision.
  • Blocking is a design decision: Six simple rules reduced 53.4 million possible pairs to 8,661 comparisons.
  • Thresholds are a business choice: Weigh the cost of merging two different people against the cost of leaving duplicates and use a grey zone for manual review.
  • Look at clusters, not just pairs: A single wrong link can chain two people together; households sharing contact details are a classic pitfall in insurance data.
  • Explainability builds trust: Waterfall charts and the cluster studio make every decision traceable, which is what business and data governance teams need in order to adopt the result.

 

As we’ve seen, probabilistic matching can help identify duplicate customer records across policy, claims, and CRM systems, even when names are misspelt, contact details have changed, or identifiers are missing. Here at ClearPeaks, we help organisations to tackle these data quality challenges and build a consistent view of their customers.

 

If duplicate records and other data quality issues are affecting your reporting, get in touch. We can guide you in the choice of matching rules that suit your data, decide which records to link automatically and which to review, and give your BI teams customer counts and KPIs they can rely on.

 

Article-Banner-Visualizations-synvert

Guillem M
guillem.medina@clearpeaks.com