Class FastPAM1.Instance

  • Direct Known Subclasses:
    FastPAM.Instance
    Enclosing class:
    FastPAM1<O>

    protected static class FastPAM1.Instance
    extends PAM.Instance
    Instance for a single dataset.
    Author:
    Erich Schubert
    • Constructor Detail

    • Method Detail

      • run

        protected double run​(ArrayModifiableDBIDs medoids,
                             int maxiter)
        Run the FastPAM optimization phase.
        Overrides:
        run in class PAM.Instance
        Parameters:
        medoids - Medoids list
        maxiter -
        Returns:
        cost
      • updatePriorCost

        protected void updatePriorCost​(double[] pcost)
        Prior assignment costs.
        Parameters:
        pcost - Prior cost.
      • assignToNearestCluster

        protected double assignToNearestCluster​(ArrayDBIDs means)
        Returns a list of clusters. The kth cluster contains the ids of those objects, that are nearest to the kth mean.
        Overrides:
        assignToNearestCluster in class PAM.Instance
        Parameters:
        means - Object centroids
        Returns:
        Assignment cost
      • computeReassignmentCost

        protected double computeReassignmentCost​(DBIDRef xj,
                                                 double[] loss)
        Compute the reassignment cost, for all medoids in one pass.
        Parameters:
        xj - Current object to swap with any medoid.
        loss - Loss change aggregation array, must have size k
        Returns:
        Loss change accumulator that applies to all
      • updateAssignment

        protected void updateAssignment​(ArrayModifiableDBIDs medoids,
                                        DBIDArrayIter miter,
                                        DBIDRef h,
                                        int m)
        Update an existing cluster assignment.
        Parameters:
        medoids - Medoids set
        miter - Medoid iterator
        h - New medoid
        m - Position of replaced medoid
      • updateSecondNearest

        protected int updateSecondNearest​(DBIDRef j,
                                          DBIDArrayIter medoids,
                                          int h,
                                          double dist_h,
                                          int n)
        Find the second nearest medoid.
        Parameters:
        j - Query point
        medoids - Medoids
        h - Known medoid
        dist_h - Distance to h
        n - Known nearest
        Returns:
        Index of second nearest medoid, PAM.Instance.second is updated.