Class KMC2.Instance
- java.lang.Object
-
- elki.clustering.kmeans.initialization.KMC2.Instance
-
- Direct Known Subclasses:
AFKMC2.Instance
- Enclosing class:
- KMC2
protected static class KMC2.Instance extends java.lang.ObjectAbstract instance implementing the weight handling.- Author:
- Erich Schubert
-
-
Field Summary
Fields Modifier and Type Field Description protected NumberVectorDistance<?>distanceDistance functionprotected longdiststatCount the number of distance computations.protected intmNumber of sampling attempts.protected java.util.RandomrandomRandom generatorprotected Relation<? extends NumberVector>relationData relation.protected WritableDoubleDataStoreweightsWeights
-
Constructor Summary
Constructors Constructor Description Instance(Relation<? extends NumberVector> relation, NumberVectorDistance<?> distance, int m, RandomFactory rnd)Constructor.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description protected voidchooseRemaining(int k, java.util.List<NumberVector> means, double weightsum)Choose remaining means, weighted by distance.protected doubledistance(NumberVector a, DBIDRef b)Compute the distance of two objects.protected doubledistance(DBIDRef cand, java.util.List<NumberVector> means)Minimum distance to the current means.protected LogginggetLogger()Class logger.protected doubleinitialWeights(NumberVector first)Initialize the weight list.double[][]run(int k)Run k-means++ initialization for number vectors.protected DBIDRefsample(double weightsum)Weighted sampling.
-
-
-
Field Detail
-
relation
protected Relation<? extends NumberVector> relation
Data relation.
-
distance
protected NumberVectorDistance<?> distance
Distance function
-
weights
protected WritableDoubleDataStore weights
Weights
-
diststat
protected long diststat
Count the number of distance computations.
-
m
protected int m
Number of sampling attempts.
-
random
protected java.util.Random random
Random generator
-
-
Constructor Detail
-
Instance
public Instance(Relation<? extends NumberVector> relation, NumberVectorDistance<?> distance, int m, RandomFactory rnd)
Constructor.- Parameters:
relation- Data relation to processdistance- Distance functionm- M parameterrnd- Random generator
-
-
Method Detail
-
initialWeights
protected double initialWeights(NumberVector first)
Initialize the weight list.- Parameters:
first- Added ID- Returns:
- Weight sum
-
run
public double[][] run(int k)
Run k-means++ initialization for number vectors.- Parameters:
k- K- Returns:
- Vectors
-
distance
protected double distance(NumberVector a, DBIDRef b)
Compute the distance of two objects.- Parameters:
a- First objectb- Second object- Returns:
- Distance
-
chooseRemaining
protected void chooseRemaining(int k, java.util.List<NumberVector> means, double weightsum)Choose remaining means, weighted by distance.- Parameters:
k- Number of means to choosemeans- Means storageweightsum- Sum of weights
-
sample
protected DBIDRef sample(double weightsum)
Weighted sampling.- Parameters:
weightsum- Total weight sum.- Returns:
- Sampled object
-
distance
protected double distance(DBIDRef cand, java.util.List<NumberVector> means)
Minimum distance to the current means.- Parameters:
cand- Candidatemeans- Current means- Returns:
- Minimum distance
-
getLogger
protected Logging getLogger()
Class logger.- Returns:
- Logger
-
-