Class JaccardDistance<T>

java.lang.Object
smile.math.distance.JaccardDistance<T>
Type Parameters:
T - the input type of distance function.
All Implemented Interfaces:
Serializable, ToDoubleBiFunction<T[],T[]>, Distance<T[]>

public class JaccardDistance<T> extends Object implements Distance<T[]>
The Jaccard index, also known as the Jaccard similarity coefficient is a statistic used for comparing the similarity and diversity of sample sets.

The Jaccard coefficient measures similarity between sample sets, and is defined as the size of the intersection divided by the size of the union of the sample sets.

The Jaccard distance, which measures dissimilarity between sample sets, is complementary to the Jaccard coefficient and is obtained by subtracting the Jaccard coefficient from 1, or, equivalently, by dividing the difference of the sizes of the union and the intersection of two sets by the size of the union.

See Also:
  • Constructor Details

    • JaccardDistance

      public JaccardDistance()
      Constructor.
  • Method Details

    • toString

      public String toString()
      Overrides:
      toString in class Object
    • d

      public double d(T[] a, T[] b)
      Description copied from interface: Distance
      Returns the distance measure between two objects.
      Specified by:
      d in interface Distance<T>
      Parameters:
      a - an object.
      b - an object.
      Returns:
      the distance.
    • d

      public static <T> double d(Set<T> a, Set<T> b)
      Returns the Jaccard distance between sets.
      Type Parameters:
      T - the data type of set elements.
      Parameters:
      a - a vector.
      b - a vector.
      Returns:
      the distance.