jaccard_index()

Calculates the Jaccard index of two input sets.

Syntax

jaccard_index(set1, set2)

Learn more about syntax conventions.

Parameters

Name Type Required Description
set1 dynamic ✔️ The array representing the first set for the calculation.
set2 dynamic ✔️ The array representing the second set for the calculation.

Note

Duplicate values in the input arrays are ignored.

Returns

The Jaccard index of the two input sets. The Jaccard index formula is |set1set2| / |set1set2|.

Examples

print set1=dynamic([1,2,3]), set2=dynamic([1,2,3,4])
| extend jaccard=jaccard_index(set1, set2)

Output

set1 set2 jaccard
[1,2,3] [1,2,3,4] 0.75