Class Linkage

java.lang.Object
smile.clustering.linkage.Linkage
Direct Known Subclasses:
CompleteLinkage, SingleLinkage, UPGMALinkage, UPGMCLinkage, WardLinkage, WPGMALinkage, WPGMCLinkage

public abstract class Linkage extends Object
A measure of dissimilarity between clusters (i.e. sets of observations).

References

  1. Anil K. Jain, Richard C. Dubes. Algorithms for clustering data. 1988.
See Also:
  • Constructor Summary

    Constructors
    Constructor
    Description
    Linkage(double[][] proximity)
    Constructor.
    Linkage(int size, float[] proximity)
    Constructor.
  • Method Summary

    Modifier and Type
    Method
    Description
    float
    d(int i, int j)
    Returns the distance/dissimilarity between two clusters/objects, which are indexed by integers.
    abstract void
    merge(int i, int j)
    Merges two clusters into one and update the proximity matrix.
    static float[]
    proximity(double[][] data)
    Computes the proximity matrix (linearized in column major) based on Euclidean distance.
    static <T> float[]
    proximity(T[] data, Distance<T> distance)
    Computes the proximity matrix (linearized in column major).
    int
    Returns the proximity matrix size.

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Constructor Details

    • Linkage

      public Linkage(double[][] proximity)
      Constructor.
      Parameters:
      proximity - the proximity matrix. Only the lower half will be referred.
    • Linkage

      public Linkage(int size, float[] proximity)
      Constructor.
      Parameters:
      size - the data size.
      proximity - the column-wise linearized proximity matrix that stores only the lower half. The length of proximity should be size * (size+1) / 2. To save space, Linkage will use this argument directly without copy. The elements may be modified.
  • Method Details

    • size

      public int size()
      Returns the proximity matrix size.
      Returns:
      the proximity matrix size.
    • d

      public float d(int i, int j)
      Returns the distance/dissimilarity between two clusters/objects, which are indexed by integers.
      Parameters:
      i - the row index of proximity matrix.
      j - the column index of proximity matrix.
      Returns:
      the distance/dissimilarity.
    • merge

      public abstract void merge(int i, int j)
      Merges two clusters into one and update the proximity matrix.
      Parameters:
      i - cluster id.
      j - cluster id.
    • proximity

      public static float[] proximity(double[][] data)
      Computes the proximity matrix (linearized in column major) based on Euclidean distance.
      Parameters:
      data - the data points.
      Returns:
      the linearized proximity matrix based on Eulidean distance.
    • proximity

      public static <T> float[] proximity(T[] data, Distance<T> distance)
      Computes the proximity matrix (linearized in column major).
      Type Parameters:
      T - the data type of points.
      Parameters:
      data - the data points.
      distance - the distance function.
      Returns:
      the linearized proximity matrix.