Package elki.clustering.kmedoids
Class FastPAM1.Instance
- java.lang.Object
-
- elki.clustering.kmedoids.PAM.Instance
-
- elki.clustering.kmedoids.FastPAM1.Instance
-
- Direct Known Subclasses:
FastPAM.Instance
protected static class FastPAM1.Instance extends PAM.Instance
Instance for a single dataset.- Author:
- Erich Schubert
-
-
Field Summary
-
Fields inherited from class elki.clustering.kmedoids.PAM.Instance
assignment, distQ, ids, nearest, second
-
-
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)
Returns a list of clusters.protected double
computeReassignmentCost(DBIDRef xj, double[] loss)
Compute the reassignment cost, for all medoids in one pass.protected double
run(ArrayModifiableDBIDs medoids, int maxiter)
Run the FastPAM optimization phase.protected void
updateAssignment(ArrayModifiableDBIDs medoids, DBIDArrayIter miter, DBIDRef h, int m)
Update an existing cluster assignment.protected void
updatePriorCost(double[] pcost)
Prior assignment costs.protected int
updateSecondNearest(DBIDRef j, DBIDArrayIter medoids, int h, double dist_h, int n)
Find the second nearest medoid.-
Methods inherited from class elki.clustering.kmedoids.PAM.Instance
computeReassignmentCost
-
-
-
-
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 FastPAM optimization phase.- Overrides:
run
in classPAM.Instance
- Parameters:
medoids
- Medoids listmaxiter
-- 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 classPAM.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 setmiter
- Medoid iteratorh
- New medoidm
- 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 pointmedoids
- Medoidsh
- Known medoiddist_h
- Distance to hn
- Known nearest- Returns:
- Index of second nearest medoid,
PAM.Instance.second
is updated.
-
-