Skip to main content

Description

Computes the Jaccard similarity coefficient between two sets (lists). The Jaccard index measures the similarity between two sets by dividing the size of their intersection by the size of their union. It returns a value between 0 (no similarity) and 1 (identical sets).

Syntax

Parameters

Returns

Type: number (float) A value between 0 and 1 representing the Jaccard similarity coefficient:
  • 1.0 indicates identical sets
  • 0.0 indicates no common elements
  • Returns null for invalid inputs

Examples

Example 1: Basic Set Similarity

Output:
(2 common elements / 4 total unique elements = 0.5)

Example 2: Finding Similar Documents by Tags

Example 3: User Interest Matching

Notes

  • Treats input lists as sets (duplicates within each list don’t affect the result)
  • Returns null if either input is not an array
  • Order of elements doesn’t matter
  • Works with any comparable data types (strings, numbers, etc.)
  • Ideal for comparing categorical attributes, tags, or interest lists

See Also

Frequently Asked Questions

It means half of the combined unique elements are shared between the two sets. The formula is |intersection| / |union|.
No. Jaccard treats inputs as sets, so element order and duplicates within a single list do not affect the result.
Any comparable data types including strings, numbers, and booleans. Both lists should contain the same type of elements for meaningful comparison.