Class PAM.Instance

  • Direct Known Subclasses:
    EagerPAM.Instance, FastPAM1.Instance, ReynoldsPAM.Instance
    Enclosing class:
    PAM<O>

    protected static class PAM.Instance
    extends java.lang.Object
    Instance for a single dataset.

    Note: we experimented with not caching the distance to nearest and second nearest, but only the assignments. The matrix lookup was more expensive, so this is probably worth the 2*n doubles in storage.

    Author:
    Erich Schubert
    • Field Summary

      Fields 
      Modifier and Type Field Description
      (package private) elki.database.datastore.WritableIntegerDataStore assignment
      Cluster mapping.
      (package private) elki.database.query.distance.DistanceQuery<?> distQ
      Distance function to use.
      (package private) elki.database.ids.DBIDs ids
      Ids to process.
      (package private) elki.database.datastore.WritableDoubleDataStore nearest
      Distance to the nearest medoid of each point.
      (package private) elki.database.datastore.WritableDoubleDataStore second
      Distance to the second nearest medoid.
    • Constructor Summary

      Constructors 
      Constructor Description
      Instance​(elki.database.query.distance.DistanceQuery<?> distQ, elki.database.ids.DBIDs ids, elki.database.datastore.WritableIntegerDataStore assignment)
      Constructor.
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      protected double assignToNearestCluster​(elki.database.ids.ArrayDBIDs means)
      Assign each object to the nearest cluster, return the cost.
      protected double computeReassignmentCost​(elki.database.ids.DBIDRef h, int mnum)
      Compute the reassignment cost of one swap.
      protected double run​(elki.database.ids.ArrayModifiableDBIDs medoids, int maxiter)
      Run the PAM optimization phase.
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Field Detail

      • ids

        elki.database.ids.DBIDs ids
        Ids to process.
      • distQ

        elki.database.query.distance.DistanceQuery<?> distQ
        Distance function to use.
      • nearest

        elki.database.datastore.WritableDoubleDataStore nearest
        Distance to the nearest medoid of each point.
      • second

        elki.database.datastore.WritableDoubleDataStore second
        Distance to the second nearest medoid.
      • assignment

        elki.database.datastore.WritableIntegerDataStore assignment
        Cluster mapping.
    • Constructor Detail

      • Instance

        public Instance​(elki.database.query.distance.DistanceQuery<?> distQ,
                        elki.database.ids.DBIDs ids,
                        elki.database.datastore.WritableIntegerDataStore assignment)
        Constructor.
        Parameters:
        distQ - Distance query
        ids - IDs to process
        assignment - Cluster assignment
    • Method Detail

      • run

        protected double run​(elki.database.ids.ArrayModifiableDBIDs medoids,
                             int maxiter)
        Run the PAM optimization phase.
        Parameters:
        medoids - Initial medoids list
        maxiter - Maximum number of iterations
        Returns:
        final cost
      • computeReassignmentCost

        protected double computeReassignmentCost​(elki.database.ids.DBIDRef h,
                                                 int mnum)
        Compute the reassignment cost of one swap.
        Parameters:
        h - Current object to swap with the medoid
        mnum - Medoid number to be replaced
        Returns:
        cost
      • assignToNearestCluster

        protected double assignToNearestCluster​(elki.database.ids.ArrayDBIDs means)
        Assign each object to the nearest cluster, return the cost.
        Parameters:
        means - Object centroids
        Returns:
        Assignment cost