Documentation of 'org.ddogleg.clustering.kmeans.AssignKMeans_F64' Java class
AssignKMeans_F64
org.ddogleg.clustering.kmeans

Class AssignKMeans_F64

  • All Implemented Interfaces:
    java.io.Serializable, AssignCluster<double[]>


    public class AssignKMeans_F64
    extends java.lang.Object
    implements AssignCluster<double[]>
    Implementation of AssignCluster for K-Means. Euclidean distance squared is used to select the best fit clusters to a point. This distance metric works well for hard assignment but can produce undesirable results for soft assignment, see JavaDoc.
    See Also:
    Serialized Form
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method and Description
      int assign(double[] point)
      Assigns the point to cluster which is the best fit.
      void assign(double[] point, double[] fit)
      Soft assignment is done by summing the total distance of the point from each cluster.
      AssignCluster<double[]> copy()
      Creates an exact copy of this class.
      java.util.List<double[]> getClusters() 
      int getNumberOfClusters()
      Total number of clusters.
      void setClusters(java.util.List<double[]> clusters) 
      • Methods inherited from class java.lang.Object

        equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Constructor Detail

      • AssignKMeans_F64

        public AssignKMeans_F64(java.util.List<double[]> clusters)
    • Method Detail

      • assign

        public int assign(double[] point)
        Description copied from interface: AssignCluster
        Assigns the point to cluster which is the best fit.
        Specified by:
        assign in interface AssignCluster<double[]>
        Parameters:
        point - Point which is to be assigned
        Returns:
        Index of the cluster from 0 to N-1
      • assign

        public void assign(double[] point,
                           double[] fit)

        Soft assignment is done by summing the total distance of the point from each cluster. Then for each cluster its value is set to total minus its distance. The output array is then normalized by dividing each element by the sum.

        When all clusters are approximately the same distance or one is clearly the closest this produces reasonable results. When multiple clusters are much closer than at least on other cluster then it effectively ignores the relative difference in distances between the closest points. There are several obvious heuristic "fixes" to this issue, but the best way to solve it is to simply use AssignGmm_F64 instead.

        Specified by:
        assign in interface AssignCluster<double[]>
        Parameters:
        point - Point which is to be assigned
        fit - Storage for relative fit quality of each cluster. Length must be at least the number of clusters.
      • getNumberOfClusters

        public int getNumberOfClusters()
        Description copied from interface: AssignCluster
        Total number of clusters.
        Specified by:
        getNumberOfClusters in interface AssignCluster<double[]>
        Returns:
        The total number of clusters.
      • getClusters

        public java.util.List<double[]> getClusters()
      • setClusters

        public void setClusters(java.util.List<double[]> clusters)

DataMelt 3.0 © DataMelt by jWork.ORG

You see the box below because you did not login.