daft.functions.hamming_distance#
hamming_distance #
hamming_distance(left: Expression, right: Expression) -> Expression
Compute the Hamming distance (number of differing bits) between two hash fingerprints.
Counts the number of differing bits (popcount of XOR). Supports integer inputs (e.g., UInt64 from simhash) and FixedSizeBinary inputs (e.g., from image_hash).
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
left | Integer or FixedSizeBinary Expression | The left fingerprint. | required |
right | Integer or FixedSizeBinary Expression | The right fingerprint (must match left's type). | required |
Returns:
| Name | Type | Description |
|---|---|---|
Expression | UInt32 Expression | Number of differing bits. |
Source code in daft/functions/similarity.py
8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 | |