Class LAB<O>
- java.lang.Object
-
- elki.clustering.kmedoids.initialization.LAB<O>
-
- Type Parameters:
O
- Object type for KMedoids initialization
- All Implemented Interfaces:
KMeansInitialization
,KMedoidsInitialization<O>
@Reference(authors="Erich Schubert, Peter J. Rousseeuw", title="Faster k-Medoids Clustering: Improving the PAM, CLARA, and CLARANS Algorithms", booktitle="Proc. 12th Int. Conf. Similarity Search and Applications (SISAP\'2019)", url="https://doi.org/10.1007/978-3-030-32047-8_16", bibkey="DBLP:conf/sisap/SchubertR19") public class LAB<O> extends java.lang.Object implements KMeansInitialization, KMedoidsInitialization<O>
Linear approximative BUILD (LAB) initialization for FastPAM (and k-means).This is a O(nk) aproximation of the original PAM BUILD. For performance, it uses an O(sqrt(n)) sample to achieve linear run time. The results will be worse than those of BUILD, but provide a good starting point for FastPAM optimization.
Reference:
Erich Schubert, Peter J. Rousseeuw
Faster k-Medoids Clustering: Improving the PAM, CLARA, and CLARANS Algorithms
Proc. 12th Int. Conf. Similarity Search and Applications (SISAP'2019)- Since:
- 0.7.5
- Author:
- Erich Schubert
-
-
Field Summary
Fields Modifier and Type Field Description private static Logging
LOG
Class logger.private RandomFactory
rnd
Random generator
-
Constructor Summary
Constructors Constructor Description LAB(RandomFactory rnd)
Constructor.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description double[][]
chooseInitialMeans(Relation<? extends NumberVector> relation, int k, NumberVectorDistance<?> distance)
Choose initial meansDBIDs
chooseInitialMedoids(int k, DBIDs ids, DistanceQuery<? super O> distQ)
Choose initial meansprotected static double
getMinDist(DBIDArrayIter j, DistanceQuery<?> distQ, DBIDArrayIter mi, WritableDoubleDataStore mindist)
Get the minimum distance to previous medoids.private static void
shuffle(ArrayModifiableDBIDs ids, int ssize, int end, java.util.Random random)
Partial Fisher-Yates shuffle.
-
-
-
Field Detail
-
LOG
private static final Logging LOG
Class logger.
-
rnd
private RandomFactory rnd
Random generator
-
-
Constructor Detail
-
LAB
public LAB(RandomFactory rnd)
Constructor.- Parameters:
rnd
- Random generator
-
-
Method Detail
-
chooseInitialMeans
public double[][] chooseInitialMeans(Relation<? extends NumberVector> relation, int k, NumberVectorDistance<?> distance)
Description copied from interface:KMeansInitialization
Choose initial means- Specified by:
chooseInitialMeans
in interfaceKMeansInitialization
- Parameters:
relation
- Relationk
- Parameter kdistance
- Distance function- Returns:
- List of chosen means for k-means
-
chooseInitialMedoids
public DBIDs chooseInitialMedoids(int k, DBIDs ids, DistanceQuery<? super O> distQ)
Description copied from interface:KMedoidsInitialization
Choose initial means- Specified by:
chooseInitialMedoids
in interfaceKMedoidsInitialization<O>
- Parameters:
k
- Parameter kids
- Candidate IDs.distQ
- Distance function- Returns:
- List of chosen means for k-means
-
getMinDist
protected static double getMinDist(DBIDArrayIter j, DistanceQuery<?> distQ, DBIDArrayIter mi, WritableDoubleDataStore mindist)
Get the minimum distance to previous medoids.- Parameters:
j
- current objectdistQ
- distance querymi
- medoid iteratormindist
- distance storage- Returns:
- minimum distance
-
shuffle
private static void shuffle(ArrayModifiableDBIDs ids, int ssize, int end, java.util.Random random)
Partial Fisher-Yates shuffle.- Parameters:
ids
- IDs to shufflessize
- sample size to generateend
- Valid rangerandom
- Random generator
-
-