Without Ground-Truth file?#

No problem! pyJedAI can still help you with your data integration tasks.

Don’t have a ground-trouth file? It’s ok as many pyJedAI workflows don’t need it. Though you can’t evaluate the performance, there are other indicators that show our unsupervised methods performance.

In this notebook we present the pyJedAI approach in the well-known ABT-BUY dataset but without a Ground-Truth file. Clean-Clean ER in the link discovery/deduplication between two sets of entities.

Dataset: Abt-Buy dataset

The Abt-Buy dataset for entity resolution derives from the online retailers Abt.com and Buy.com. The dataset contains 1076 entities from abt.com and 1076 entities from buy.com as well as a gold standard (perfect mapping) with 1076 matching record pairs between the two data sources. The common attributes between the two data sources are: product name, product description and product price.

How to install?#

pyJedAI is an open-source library that can be installed from PyPI.

For more: pypi.org/project/pyjedai/

!pip install pyjedai -U
!pip show pyjedai
Name: pyjedai
Version: 0.1.0
Summary: An open-source library that builds powerful end-to-end Entity Resolution workflows.
Home-page: 
Author: 
Author-email: Konstantinos Nikoletos <nikoletos.kon@gmail.com>, George Papadakis <gpapadis84@gmail.com>, Jakub Maciejewski <jacobb.maciejewski@gmail.com>, Manolis Koubarakis <koubarak@di.uoa.gr>
License: Apache Software License 2.0
Location: /home/jm/anaconda3/envs/pyjedai-new/lib/python3.8/site-packages
Requires: faiss-cpu, gensim, matplotlib, matplotlib-inline, networkx, nltk, numpy, optuna, ordered-set, pandas, pandas-profiling, pandocfilters, plotly, py-stringmatching, PyYAML, rdflib, rdfpandas, regex, scipy, seaborn, sentence-transformers, strsim, strsimpy, tomli, tqdm, transformers, valentine
Required-by: 

Imports

import os
import sys
import pandas as pd
import networkx
from networkx import draw, Graph
import pyjedai
from pyjedai.utils import (
    text_cleaning_method,
    print_clusters,
    print_blocks,
    print_candidate_pairs
)
from pyjedai.evaluation import Evaluation

Workflow Architecture#

workflow-example.png

Data Reading#

pyJedAI in order to perfrom needs only the tranformation of the initial data into a pandas DataFrame. Hence, pyJedAI can function in every structured or semi-structured data. In this case Abt-Buy dataset is provided as .csv files.

from pyjedai.datamodel import Data
from pyjedai.evaluation import Evaluation
d1 = pd.read_csv("./../data/ccer/D2/abt.csv", sep='|', engine='python', na_filter=False).astype(str)
d2 = pd.read_csv("./../data/ccer/D2/buy.csv", sep='|', engine='python', na_filter=False).astype(str)

data = Data(
    dataset_1=d1,
    attributes_1=['id','name','description'],
    id_column_name_1='id',
    dataset_2=d2,
    attributes_2=['id','name','description'],
    id_column_name_2='id'
)

pyJedAI offers also dataset analysis methods (more will be developed)

data.print_specs()
***************************************************************************************************************************
                                                   Data Report
***************************************************************************************************************************
Type of Entity Resolution:  Clean-Clean
Dataset 1 (D1):
	Number of entities:  1076
	Number of NaN values:  0
	Memory usage [KB]:  563.56
	Attributes:
		 id
		 name
		 description
Dataset 2 (D2):
	Number of entities:  1076
	Number of NaN values:  0
	Memory usage [KB]:  336.63
	Attributes:
		 id
		 name
		 description

Total number of entities:  2152
───────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────
data.dataset_1.head(5)
id name description price
0 0 Sony Turntable - PSLX350H Sony Turntable - PSLX350H/ Belt Drive System/ ...
1 1 Bose Acoustimass 5 Series III Speaker System -... Bose Acoustimass 5 Series III Speaker System -... 399
2 2 Sony Switcher - SBV40S Sony Switcher - SBV40S/ Eliminates Disconnecti... 49
3 3 Sony 5 Disc CD Player - CDPCE375 Sony 5 Disc CD Player- CDPCE375/ 5 Disc Change...
4 4 Bose 27028 161 Bookshelf Pair Speakers In Whit... Bose 161 Bookshelf Speakers In White - 161WH/ ... 158
data.dataset_2.head(5)
id name description price
0 0 Linksys EtherFast EZXS88W Ethernet Switch - EZ... Linksys EtherFast 8-Port 10/100 Switch (New/Wo...
1 1 Linksys EtherFast EZXS55W Ethernet Switch 5 x 10/100Base-TX LAN
2 2 Netgear ProSafe FS105 Ethernet Switch - FS105NA NETGEAR FS105 Prosafe 5 Port 10/100 Desktop Sw...
3 3 Belkin Pro Series High Integrity VGA/SVGA Moni... 1 x HD-15 - 1 x HD-15 - 10ft - Beige
4 4 Netgear ProSafe JFS516 Ethernet Switch Netgear ProSafe 16 Port 10/100 Rackmount Switc...

Block Building#

It clusters entities into overlapping blocks in a lazy manner that relies on unsupervised blocking keys: every token in an attribute value forms a key. Blocks are then extracted, possibly using a transformation, based on its equality or on its similarity with other keys.

The following methods are currently supported:

  • Standard/Token Blocking

  • Sorted Neighborhood

  • Extended Sorted Neighborhood

  • Q-Grams Blocking

  • Extended Q-Grams Blocking

  • Suffix Arrays Blocking

  • Extended Suffix Arrays Blocking

from pyjedai.block_building import (
    StandardBlocking,
    QGramsBlocking,
    ExtendedQGramsBlocking,
    SuffixArraysBlocking,
    ExtendedSuffixArraysBlocking,
)

from pyjedai.vector_based_blocking import EmbeddingsNNBlockBuilding
/home/conda/miniconda3/envs/pypi_dependencies/lib/python3.9/site-packages/tqdm/auto.py:21: TqdmWarning: IProgress not found. Please update jupyter and ipywidgets. See https://ipywidgets.readthedocs.io/en/stable/user_install.html
  from .autonotebook import tqdm as notebook_tqdm
qgb = SuffixArraysBlocking()
blocks = qgb.build_blocks(data, attributes_1=['name'], attributes_2=['name'])
Suffix Arrays Blocking: 100%|██████████| 2152/2152 [00:00<00:00, 28038.64it/s]
qgb.report()
Method name: Suffix Arrays Blocking
Method info: Creates one block for every suffix that appears in the attribute value tokens of at least two entities.
Parameters: 
	Suffix length: 6
	Maximum Block Size: 53
Attributes from D1:
	name
Attributes from D2:
	name
Runtime: 0.0786 seconds

Block Cleaning#

Optional step

Its goal is to clean a set of overlapping blocks from unnecessary comparisons, which can be either redundant (i.e., repeated comparisons that have already been executed in a previously examined block) or superfluous (i.e., comparisons that involve non-matching entities). Its methods operate on the coarse level of individual blocks or entities.

from pyjedai.block_cleaning import BlockPurging
cbbp = BlockPurging()
cleaned_blocks = cbbp.process(blocks, data, tqdm_disable=False)
Block Purging: 100%|██████████| 5908/5908 [00:00<00:00, 413709.33it/s]
cbbp.report()
Method name: Block Purging
Method info: Discards the blocks exceeding a certain number of comparisons.
Parameters: 
	Smoothing factor: 1.025
	Max Comparisons per Block: 702.0
Runtime: 0.0167 seconds
from pyjedai.block_cleaning import BlockFiltering
bf = BlockFiltering(ratio=0.8)
filtered_blocks = bf.process(cleaned_blocks, data, tqdm_disable=False)
Block Filtering: 100%|██████████| 3/3 [00:00<00:00, 72.91it/s]

Comparison Cleaning#

Optional step

Similar to Block Cleaning, this step aims to clean a set of blocks from both redundant and superfluous comparisons. Unlike Block Cleaning, its methods operate on the finer granularity of individual comparisons.

The following methods are currently supported:

  • Comparison Propagation

  • Cardinality Edge Pruning (CEP)

  • Cardinality Node Pruning (CNP)

  • Weighed Edge Pruning (WEP)

  • Weighed Node Pruning (WNP)

  • Reciprocal Cardinality Node Pruning (ReCNP)

  • Reciprocal Weighed Node Pruning (ReWNP)

  • BLAST

Most of these methods are Meta-blocking techniques. All methods are optional, but competive, in the sense that only one of them can part of an ER workflow. For more details on the functionality of these methods, see here. They can be combined with one of the following weighting schemes:

  • Aggregate Reciprocal Comparisons Scheme (ARCS)

  • Common Blocks Scheme (CBS)

  • Enhanced Common Blocks Scheme (ECBS)

  • Jaccard Scheme (JS)

  • Enhanced Jaccard Scheme (EJS)

Meta Blocking#

from pyjedai.comparison_cleaning import (
    WeightedEdgePruning,
    WeightedNodePruning,
    CardinalityEdgePruning,
    CardinalityNodePruning,
    BLAST,
    ReciprocalCardinalityNodePruning,
    ReciprocalWeightedNodePruning,
    ComparisonPropagation
)
wep = CardinalityEdgePruning(weighting_scheme='X2')
candidate_pairs_blocks = wep.process(filtered_blocks, data, tqdm_disable=True)

Entity Matching#

It compares pairs of entity profiles, associating every pair with a similarity in [0,1]. Its output comprises the similarity graph, i.e., an undirected, weighted graph where the nodes correspond to entities and the edges connect pairs of compared entities.

from pyjedai.matching import EntityMatching
EM = EntityMatching(
    metric='dice',
    similarity_threshold=0.5,
    attributes = ['description', 'name']
)

pairs_graph = EM.predict(candidate_pairs_blocks, data, tqdm_disable=True)
draw(pairs_graph)
../_images/af4764935145fd0c862373f4e49d4a51415027a79814eb127941cbd7bc50de7d.png

Entity Clustering#

It takes as input the similarity graph produced by Entity Matching and partitions it into a set of equivalence clusters, with every cluster corresponding to a distinct real-world object.

from pyjedai.clustering import ConnectedComponentsClustering
ccc = ConnectedComponentsClustering()
clusters = ccc.process(pairs_graph, data)

K. Nikoletos, J. Maciejewski, G. Papadakis & M. Koubarakis