Class RandIndex

java.lang.Object
smile.validation.metric.RandIndex
All Implemented Interfaces:
Serializable, ClusteringMetric

public class RandIndex extends Object implements ClusteringMetric
Rand Index. Rand index is defined as the number of pairs of objects that are either in the same group or in different groups in both partitions divided by the total number of pairs of objects. The Rand index lies between 0 and 1. When two partitions agree perfectly, the Rand index achieves the maximum value 1. A problem with Rand index is that the expected value of the Rand index between two random partitions is not a constant. This problem is corrected by the adjusted Rand index that assumes the generalized hyper-geometric distribution as the model of randomness. The adjusted Rand index has the maximum value 1, and its expected value is 0 in the case of random clusters. A larger adjusted Rand index means a higher agreement between two partitions. The adjusted Rand index is recommended for measuring agreement even when the partitions compared have different numbers of clusters.
See Also:
  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    static final RandIndex
    Default instance.
  • Constructor Summary

    Constructors
    Constructor
    Description
     
  • Method Summary

    Modifier and Type
    Method
    Description
    static double
    of(int[] truth, int[] cluster)
    Calculates the rand index.
    double
    score(int[] truth, int[] cluster)
    Returns a score to measure the quality of clustering.
     

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
  • Field Details

    • instance

      public static final RandIndex instance
      Default instance.
  • Constructor Details

    • RandIndex

      public RandIndex()
  • Method Details

    • score

      public double score(int[] truth, int[] cluster)
      Description copied from interface: ClusteringMetric
      Returns a score to measure the quality of clustering.
      Specified by:
      score in interface ClusteringMetric
      Parameters:
      truth - the ground truth (or simply a clustering labels).
      cluster - the alternative cluster labels.
      Returns:
      the metric.
    • of

      public static double of(int[] truth, int[] cluster)
      Calculates the rand index.
      Parameters:
      truth - the ground truth (or simply a clustering labels).
      cluster - the alternative cluster labels.
      Returns:
      the metric.
    • toString

      public String toString()
      Overrides:
      toString in class Object