Package elki.clustering.silhouette
Class FastMSC.Instance
- java.lang.Object
-
- elki.clustering.silhouette.FastMSC.Instance
-
- Direct Known Subclasses:
FasterMSC.Instance
protected class FastMSC.Instance extends java.lang.ObjectFastMSC clustering instance for a particular data set.- Author:
- Erich Schubert
-
-
Field Summary
Fields Modifier and Type Field Description protected WritableDataStore<FastMSC.Record>assignmentDistances and nearest medoids.protected DistanceQuery<?>distQDistance function to use.protected DBIDsidsIds to process.protected WritableIntegerDataStoreoutputOutput cluster mapping.
-
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 doubleassignToNearestCluster(ArrayDBIDs means)Assign each object to the nearest cluster.protected doubledoSwap(ArrayDBIDs medoids, int b, DBIDRef j)Assign each object to the nearest cluster when replacing one medoid.protected doublefindBestSwap(DBIDRef j, double[] ploss)Compute the loss change when choosing j as new medoid.protected doublerun(ArrayModifiableDBIDs medoids, int maxiter)Run the FastMSC optimization phase.DoubleDataStoresilhouetteScores()Get the silhouette scores per point (must be run() first)protected voidupdateRemovalLoss(double[] losses)Update the share removal loss dataprotected voidupdateThirdNearest(DBIDRef j, FastMSC.Record rec, int m, double bestd, DBIDArrayIter miter)Update the third nearest in the record.
-
-
-
Field Detail
-
ids
protected DBIDs ids
Ids to process.
-
distQ
protected DistanceQuery<?> distQ
Distance function to use.
-
assignment
protected WritableDataStore<FastMSC.Record> assignment
Distances and nearest medoids.
-
output
protected WritableIntegerDataStore output
Output 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 FastMSC optimization phase.- Parameters:
medoids- Initial medoids listmaxiter- Maximum number of iterations- Returns:
- final medoid Silhouette
-
assignToNearestCluster
protected double assignToNearestCluster(ArrayDBIDs means)
Assign each object to the nearest cluster.- Parameters:
means- Cluster medoids- Returns:
- loss
-
findBestSwap
protected double findBestSwap(DBIDRef j, double[] ploss)
Compute the loss change when choosing j as new medoid.- Parameters:
j- New medoidploss- Loss array- Returns:
- Shared loss term
-
doSwap
protected double doSwap(ArrayDBIDs medoids, int b, DBIDRef j)
Assign each object to the nearest cluster when replacing one medoid.- Parameters:
medoids- Cluster medoidsb- Medoid position indexj- New medoid- Returns:
- medoid silhouette
-
updateThirdNearest
protected void updateThirdNearest(DBIDRef j, FastMSC.Record rec, int m, double bestd, DBIDArrayIter miter)
Update the third nearest in the record.- Parameters:
j- Current objectrec- Current recordm- Medoid id replacedbestd- distance to medoidmiter- Medoid iterator
-
updateRemovalLoss
protected void updateRemovalLoss(double[] losses)
Update the share removal loss data- Parameters:
losses- Removal loss storage
-
silhouetteScores
public DoubleDataStore silhouetteScores()
Get the silhouette scores per point (must be run() first)- Returns:
- Silhouette scores
-
-