Class TaxonomicDistance

java.lang.Object
smile.taxonomy.TaxonomicDistance
All Implemented Interfaces:
Serializable, ToDoubleBiFunction<Concept,Concept>, Distance<Concept>

public class TaxonomicDistance extends Object implements Distance<Concept>
The distance between concepts in a taxonomy. The distance between two concepts a and b is defined by the length of the path from a to their lowest common ancestor and then to b.
See Also:
  • Constructor Details

    • TaxonomicDistance

      public TaxonomicDistance(Taxonomy taxonomy)
      Constructor.
      Parameters:
      taxonomy - the taxonomy that this distance is associated with.
  • Method Details

    • toString

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

      public double d(String x, String y)
      Computes the distance between two concepts in a taxonomy.
      Parameters:
      x - a concept.
      y - the other concept.
      Returns:
      the distance.
    • d

      public double d(Concept x, Concept y)
      Computes the distance between two concepts in a taxonomy.
      Specified by:
      d in interface Distance<Concept>
      Parameters:
      x - an object.
      y - an object.
      Returns:
      the distance.