Weighted deterministic
matchlab.models.linkers.weighteddeterministic
¶
A linking methodology that applies different weights to field comparisons.
Classes:
-
WeightedComparison–A comparison condition, and the weight it contributes to a pair's score.
-
WeightedDeterministicLinker–Scores a pair by the weighted share of comparisons it matches on.
WeightedComparison
¶
Bases: BaseModel
flowchart TD
matchlab.models.linkers.weighteddeterministic.WeightedComparison[WeightedComparison]
click matchlab.models.linkers.weighteddeterministic.WeightedComparison href "" "matchlab.models.linkers.weighteddeterministic.WeightedComparison"
A comparison condition, and the weight it contributes to a pair's score.
Methods:
-
validate_comparison–Validate the comparison string.
Attributes:
-
comparison(SQLCondition) – -
weight(float) –
comparison
class-attribute
instance-attribute
¶
comparison: SQLCondition = Field(description='\n A valid ON clause comparing fields between the left and the right data.\n\n Qualify every column with `l` or `r`. For example:\n\n "l.company_name = r.company_name"\n ')
weight
class-attribute
instance-attribute
¶
weight: float = Field(description='\n A weight to give this comparison. Use 1 for all comparisons to give\n uniform weight to each.\n ')
validate_comparison
classmethod
¶
Validate the comparison string.
WeightedDeterministicLinker
¶
Bases: Linker
flowchart TD
matchlab.models.linkers.weighteddeterministic.WeightedDeterministicLinker[WeightedDeterministicLinker]
matchlab.models.linkers.base.Linker[Linker]
matchlab.models.linkers.base.Linker --> matchlab.models.linkers.weighteddeterministic.WeightedDeterministicLinker
click matchlab.models.linkers.weighteddeterministic.WeightedDeterministicLinker href "" "matchlab.models.linkers.weighteddeterministic.WeightedDeterministicLinker"
click matchlab.models.linkers.base.Linker href "" "matchlab.models.linkers.base.Linker"
Scores a pair by the weighted share of comparisons it matches on.
Methods:
-
prepare–No preparation needed.
-
link–Score each pair by summed matching weight over total weight.
Attributes:
-
version(int) – -
weighted_comparisons(list[WeightedComparison]) – -
threshold(float) – -
model_config– -
left_id(Literal['id']) – -
right_id(Literal['id']) –
weighted_comparisons
class-attribute
instance-attribute
¶
weighted_comparisons: list[WeightedComparison] = Field(description='A list of tuples in the form of a comparison, and a weight.')
threshold
class-attribute
instance-attribute
¶
threshold: float = Field(description='\n The score above which matches will be kept. \n \n Inclusive, so a value of 1 will keep only exact matches across all \n comparisons.\n ', ge=0, le=1)
model_config
class-attribute
instance-attribute
¶
left_id
class-attribute
instance-attribute
¶
left_id: Literal['id'] = Field(default='id', description='The unique ID field in the left data')
right_id
class-attribute
instance-attribute
¶
right_id: Literal['id'] = Field(default='id', description='The unique ID field in the right data')
link
¶
Score each pair by summed matching weight over total weight.
Keeps only pairs scoring at or above settings.threshold.