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.Object
FastMSC clustering instance for a particular data set.- Author:
- Erich Schubert
-
-
Field Summary
Fields Modifier and Type Field Description protected WritableDataStore<FastMSC.Record>
assignment
Distances and nearest medoids.protected DistanceQuery<?>
distQ
Distance function to use.protected DBIDs
ids
Ids to process.protected WritableIntegerDataStore
output
Output 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 double
assignToNearestCluster(ArrayDBIDs means)
Assign each object to the nearest cluster.protected double
doSwap(ArrayDBIDs medoids, int b, DBIDRef j)
Assign each object to the nearest cluster when replacing one medoid.protected double
findBestSwap(DBIDRef j, double[] ploss)
Compute the loss change when choosing j as new medoid.protected double
run(ArrayModifiableDBIDs medoids, int maxiter)
Run the FastMSC optimization phase.DoubleDataStore
silhouetteScores()
Get the silhouette scores per point (must be run() first)protected void
updateRemovalLoss(double[] losses)
Update the share removal loss dataprotected void
updateThirdNearest(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
-
-