Class BIRCHKMeansPlusPlus
- java.lang.Object
-
- elki.clustering.hierarchical.birch.BIRCHKMeansPlusPlus
-
public class BIRCHKMeansPlusPlus extends java.lang.Object
K-Means++-like initialization for BIRCH k-means; this cannot be used to initialize regular k-means, useKMeansPlusPlus
instead.- Since:
- 0.8.0
- Author:
- Andreas Lang
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static class
BIRCHKMeansPlusPlus.Par
Parameterization class.
-
Field Summary
Fields Modifier and Type Field Description protected RandomFactory
random
Random generatorprotected double[]
weights
Weights
-
Constructor Summary
Constructors Constructor Description BIRCHKMeansPlusPlus(RandomFactory rnd)
Constructor.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description private double
distance(double[] ds, double[] ds2)
Calculates distance between two vectors.private double
initialWeights(double[] first, double[][] x)
Initialize the weight list.double[][]
run(double[][] x, int k)
Perform k-means++ initialization.private double
updateWeights(double[] latest, double[][] x)
Update the weight list.
-
-
-
Field Detail
-
random
protected RandomFactory random
Random generator
-
weights
protected double[] weights
Weights
-
-
Constructor Detail
-
BIRCHKMeansPlusPlus
public BIRCHKMeansPlusPlus(RandomFactory rnd)
Constructor.- Parameters:
rnd
- Random generator.
-
-
Method Detail
-
run
public double[][] run(double[][] x, int k)
Perform k-means++ initialization.- Parameters:
x
- Input vectors.k
- K- Returns:
- Initial cluster centers
-
initialWeights
private double initialWeights(double[] first, double[][] x)
Initialize the weight list.- Parameters:
first
- Id of first mean.x
- Input data.- Returns:
- Sum of weights
-
distance
private double distance(double[] ds, double[] ds2)
Calculates distance between two vectors.- Parameters:
ds
- First Vectords2
- Second Vector- Returns:
- Vector
-
updateWeights
private double updateWeights(double[] latest, double[][] x)
Update the weight list.- Parameters:
latest
- Latest center- Returns:
- Weight sum
-
-