Class YinYangKMeans.Instance

    • Field Detail

      • groups

        int[][] groups
        Center list for each group
      • gdrift

        double[] gdrift
        Maximum distance moved within each group.
      • cdrift

        double[] cdrift
        Distance moved by each center.
      • sums

        double[][] sums
        Current cluster sum.
      • glabel

        int[] glabel
        Group label of each mean
    • Constructor Detail

      • Instance

        public Instance​(Relation<? extends NumberVector> relation,
                        NumberVectorDistance<?> df,
                        double[][] means,
                        int t)
        Constructor.
        Parameters:
        relation - Data relation
        df - Distance function
        means - Initial means
        t - Number of groups to use
    • Method Detail

      • groupKMeans

        private int[][] groupKMeans​(int t)
        Groups the initial centers into t groups.
        Parameters:
        t - Number of groups
        Returns:
        a list of groups containing mean indices.
      • initialGroupAssignment

        private void initialGroupAssignment​(int t,
                                            double[][] scratch,
                                            int[] gweight)
        Initial k-means assignment for centers to groups.
        Parameters:
        t - Number of groups
        scratch - Scratch space for means
        gweight - group weights
      • updateGroupAssignment

        private boolean updateGroupAssignment​(int t,
                                              double[][] gmeans,
                                              int[] gweight)
        Perform one step of Voronoi refinement.
        Parameters:
        t - Number of groups
        gmeans - current group means
        gweight - Group weight
        Returns:
        true if changed
      • iterate

        protected int iterate​(int iteration)
        Description copied from class: AbstractKMeans.Instance
        Main loop function.
        Specified by:
        iterate in class AbstractKMeans.Instance
        Parameters:
        iteration - Iteration number (beginning at 1)
        Returns:
        Number of reassigned points
      • updateCenters

        private void updateCenters()
        Update centers and how much they moved.
      • assignToNearestCluster

        protected int assignToNearestCluster()
        Reassign objects, but avoid unnecessary computations based on their bounds.
        Overrides:
        assignToNearestCluster in class AbstractKMeans.Instance
        Returns:
        number of objects reassigned
      • initialAssignToNearestCluster

        private int initialAssignToNearestCluster()
        Perform initial cluster assignment,
        Returns:
        number of changes (i.e. relation size)