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.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) WritableIntegerDataStore
assignment
Cluster mapping.(package private) DistanceQuery<?>
distQ
Distance function to use.(package private) DBIDs
ids
Ids to process.(package private) WritableDoubleDataStore
nearest
Distance to the nearest medoid of each point.(package private) WritableDoubleDataStore
second
Distance to the second nearest medoid.
-
Constructor Summary
Constructors Constructor Description Instance(DistanceQuery<?> distQ, DBIDs ids, WritableIntegerDataStore assignment)
Constructor.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description protected double
assignToNearestCluster(ArrayDBIDs means)
Assign each object to the nearest cluster, return the cost.protected double
computeReassignmentCost(DBIDRef h, int mnum)
Compute the reassignment cost of one swap.protected double
run(ArrayModifiableDBIDs medoids, int maxiter)
Run the PAM optimization phase.
-
-
-
Field Detail
-
ids
DBIDs ids
Ids to process.
-
distQ
DistanceQuery<?> distQ
Distance function to use.
-
nearest
WritableDoubleDataStore nearest
Distance to the nearest medoid of each point.
-
second
WritableDoubleDataStore second
Distance to the second nearest medoid.
-
assignment
WritableIntegerDataStore assignment
Cluster mapping.
-
-
Constructor Detail
-
Instance
public Instance(DistanceQuery<?> distQ, DBIDs ids, WritableIntegerDataStore assignment)
Constructor.- Parameters:
distQ
- Distance queryids
- IDs to processassignment
- Cluster assignment
-
-
Method Detail
-
run
protected double run(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(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(ArrayDBIDs means)
Assign each object to the nearest cluster, return the cost.- Parameters:
means
- Object centroids- Returns:
- Assignment cost
-
-