Package elki.clustering.kmedoids
Class PAM.Instance
- java.lang.Object
-
- elki.clustering.kmedoids.PAM.Instance
-
- Direct Known Subclasses:
EagerPAM.Instance,FastPAM1.Instance,ReynoldsPAM.Instance
protected static class PAM.Instance extends java.lang.ObjectInstance 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.WritableIntegerDataStoreassignmentCluster mapping.(package private) elki.database.query.distance.DistanceQuery<?>distQDistance function to use.(package private) elki.database.ids.DBIDsidsIds to process.(package private) elki.database.datastore.WritableDoubleDataStorenearestDistance to the nearest medoid of each point.(package private) elki.database.datastore.WritableDoubleDataStoresecondDistance 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 doubleassignToNearestCluster(elki.database.ids.ArrayDBIDs means)Assign each object to the nearest cluster, return the cost.protected doublecomputeReassignmentCost(elki.database.ids.DBIDRef h, int mnum)Compute the reassignment cost of one swap.protected doublerun(elki.database.ids.ArrayModifiableDBIDs medoids, int maxiter)Run the PAM optimization phase.
-
-
-
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.
-
-
Method Detail
-
run
protected double run(elki.database.ids.ArrayModifiableDBIDs medoids, int maxiter)Run the PAM optimization phase.- Parameters:
medoids- Initial medoids listmaxiter- 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 medoidmnum- 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
-
-