dedupe Python Library

repository·main·Indexed 26 days ago

https://github.com/dedupeio/dedupe

A Python library for accurate and scalable data deduplication and entity resolution. It uses machine learning and active learning to perform fuzzy matching on structured data, learning similarity rules from human training data. The library provides core API classes including Dedupe for finding duplicates in a dataset, RecordLink for linking records between two datasets, and Gazetteer for matching records against a canonical index.

Tokens
14.8K
Snippets
26
Records
114
Agent score
86%

What's inside dedupe

  1. Overview of dedupe features

    main

    dedupe is an open-source Python library that uses machine learning to perform de-duplication and entity resolution on structured data.

    Key capabilities include:

    • Machine Learning: Automatically creates optimum weights and blocking rules by reading human-labeled data.
    • Efficiency: Designed to run on standard hardware (like a laptop) by making intelligent comparisons.
    • Extensibility: Supports custom data types, string comparators, and blocking rules.
    • Integration: Built as a library for easy integration into existing applications or import scripts.
  2. Optimize blocking rules with Dedupe

    main
    Dedupe automatically attempts to find an optimal set of blocking rules for your specific data. It aims to find a small set of rules that covers all labeled duplicate pairs while minimizing the total number of pairs that need to be compared. It achieves this using greedy algorithms, specifically Chvatal's Greedy Set-Cover algorithm.
  3. Understand Blocking to reduce comparisons

    main
    To avoid the computational explosion of comparing every possible pair of records in a large dataset, Dedupe uses a technique called blocking. Blocking groups records that share certain characteristics into 'blocks' and only performs comparisons within those blocks. This significantly reduces the number of comparisons needed while maintaining high confidence in finding duplicates.
  4. Explore tools built with dedupe

    main

    Beyond the core library, you can use related tools:

    • Dedupe.io: A full-service web service for de-duplicating and finding matches in messy data, providing a UI for cluster review and automation.
    • csvdedupe: A command-line tool specifically designed for de-duplicating and linking CSV files.
  5. Understand Record Linkage vs. Deduplication

    main

    Dedupe distinguishes between general deduplication and Record Linkage.

    In the general case, an arbitrary number of records in a single dataset can refer to the same entity.

    In Record Linkage, you are comparing two separate datasets to find matches between them. This scenario relies on the assumption that each dataset is individually unique. If this assumption holds, it implies:

    1. Two records can only match if they originate from different datasets.
    2. No other record in either dataset can match those two records.
  6. Explore dedupe usage examples and recipes

    main

    Dedupe is a library rather than a standalone CLI tool. To learn how to implement it, you can use various example recipes tailored for different dataset sizes and use cases.

    Detailed source code for these examples is available in the dedicated dedupe-examples repository. For interactive learning, you can view annotated walkthroughs online for specific scenarios like small data deduplication, record linkage, gazetteer usage, and database integrations (MySQL/Postgres).

  7. Use Conditional Random Field (CRF) distance for string fields

    main

    For field types String, ShortString, Address, and Name, you can enable a Conditional Random Field (CRF) distance measure by setting crf=True. This measure provides more accurate results than the default edit distance but is significantly slower to compute.

    Use this option when accuracy is more critical than processing speed for these specific field types.

    dedupe.variables.String("name", crf=True)
  8. Understand how Dedupe groups duplicate records

    main

    Dedupe uses hierarchical clustering with centroid linkage to transform pairwise duplicate probabilities into groups of records. Because pairwise probabilities are not transitive (e.g., A matches B, and B matches C, but A might not match C), the library uses a centroid-based approach where all records within a certain distance of a group's centroid are assigned to that group.

    To control the size and granularity of these groups, you must set a threshold for group membership, which defines the maximum distance from the centroid for a record to be included in a group.

  9. Extend dedupe with custom variables

    main
    When built-in variable types do not meet your requirements, you can implement your own custom variable types with custom comparators and predicates. Examples of custom variable implementations can be found in the dedupe-variable repository.
  10. Define variable collections for record matching

    main

    A variable definition is a collection of Variable objects that describes the fields you want to match. You provide these to the deduplication process to specify which record keys should be compared and how.

    import dedupe.variables
    
    [ 
        dedupe.variables.String("Site Name"),
        dedupe.variables.String("Address"),
        dedupe.variables.ShortString("Zip", has_missing=True),
        dedupe.variables.String("Phone", has_missing=True)
    ]
    import dedupe.variables
    
    [
        dedupe.variables.String("Site Name"),
        dedupe.variables.String("Address"),
        dedupe.variables.ShortString("Zip", has_missing=True),
        dedupe.variables.String("Phone", has_missing=True)
    ]