Package elki.clustering.silhouette
Class FastMSC.Instance2
- java.lang.Object
-
- elki.clustering.silhouette.FastMSC.Instance2
-
- Direct Known Subclasses:
FasterMSC.Instance2
protected class FastMSC.Instance2 extends java.lang.ObjectSimplified FastMSC clustering instance for k=2.For k=2, we can use a much simpler logic.
- Author:
- Erich Schubert
-
-
Field Summary
Fields Modifier and Type Field Description protected WritableIntegerDataStoreassignmentOutput cluster mapping.protected DistanceQuery<?>distQDistance function to use.protected WritableDoubleDataStoredm0Distances to the first medoid.protected WritableDoubleDataStoredm1Distances to the second medoid.protected DBIDsidsIds to process.
-
Constructor Summary
Constructors Constructor Description Instance2(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 voidfindBestSwap(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)
-
-
-
Field Detail
-
ids
protected DBIDs ids
Ids to process.
-
distQ
protected DistanceQuery<?> distQ
Distance function to use.
-
dm0
protected WritableDoubleDataStore dm0
Distances to the first medoid.
-
dm1
protected WritableDoubleDataStore dm1
Distances to the second medoid.
-
assignment
protected WritableIntegerDataStore assignment
Output cluster mapping.
-
-
Constructor Detail
-
Instance2
public Instance2(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 void findBestSwap(DBIDRef j, double[] ploss)
Compute the loss change when choosing j as new medoid.- Parameters:
j- New medoidploss- Loss array
-
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
-
silhouetteScores
public DoubleDataStore silhouetteScores()
Get the silhouette scores per point (must be run() first)- Returns:
- Silhouette scores
-
-