Class HartiganWongKMeans.Instance

    • Field Detail

      • r1s

        WritableDoubleDataStore r1s
        The value [NC(L1) * D(I,L1)^2] / [NC(L1) -1] will be remembered and will remain the same for Point I until cluster L1 is updated.
      • ncp

        int[] ncp
        In Optimal-transfer-stage, NCP(L) indicates the step at which cluster L is last updated. In the Quick-transfer-stage, NCP(L) is equal to the step at which cluster L is last updated plus M (number of points).
      • live

        int[] live
        Live set indicators
      • itran

        boolean[] itran
        Updated in quick-transfer
      • an1

        double[] an1
        Weights for adding/removing points from a cluster.
      • an2

        double[] an2
        Weights for adding/removing points from a cluster.
      • optries

        private int optries
        Number of attempts to make an optimal transfer.
    • Constructor Detail

      • Instance

        public Instance​(Relation<? extends NumberVector> relation,
                        NumberVectorDistance<?> df,
                        double[][] means)
        relation - Data relation
        df - Distance function
        means - Initial means
    • Method Detail

      • iterate

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

        private int initialAssignToNearestCluster()
        Step 1: For each point I, find its two closest centers, IC1(I) and IC2(I). Assign it to IC1(I).
        Number of reassigned points
      • initialize

        private void initialize()
        Initialize AN1, AN2, ITRAN, NCP
      • optimalTransfer

        private int optimalTransfer()
        In this stage, there is only one pass through the data. Each point is reallocated, if necessary, to the cluster that will induce the maximum reduction in wcss.
        Number of reassigned objects
      • quickTransfer

        private int quickTransfer()
        Step 6: the quick transfer (QTRAN) phase. Each point is tested in turn to see if it should be reallocated to the cluster which it is most likely to be transferred to IC2(I) from its present cluster IC1(I). Loop through the data until no further change is to take place.
      • cacheR1

        private double cacheR1​(DBIDIter it,
                               NumberVector vec,
                               int l1)
        Compute and cache the R1 value.
        it - Point id
        vec - Data vector
        l1 - Center id
      • transfer

        private void transfer​(DBIDRef it,
                              NumberVector vec,
                              int l1,
                              int l2)
        Transfer a point from one cluster to another.
        it - Point id
        vec - Vector
        l1 - First cluster
        l2 - Second cluster