Package elki.clustering.kmeans.parallel
Class KMeansProcessor<V extends NumberVector>
- java.lang.Object
-
- elki.clustering.kmeans.parallel.KMeansProcessor<V>
-
- All Implemented Interfaces:
Processor
public class KMeansProcessor<V extends NumberVector> extends java.lang.Object implements Processor
Parallel k-means implementation.- Since:
- 0.7.0
- Author:
- Erich Schubert
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static class
KMeansProcessor.Instance<V extends NumberVector>
Instance to process part of the data set, for a single iteration.
-
Field Summary
Fields Modifier and Type Field Description (package private) WritableIntegerDataStore
assignment
Assignment storage.(package private) double[][]
centroids
Updated cluster centroids(package private) boolean
changed
Whether the assignment changed during the last iteration.(package private) NumberVectorDistance<? super V>
distance
Distance function.(package private) double[][]
means
Mean vectors.(package private) Relation<V>
relation
Data relation.(package private) int[]
sizes
(Partial) cluster sizes(package private) double[]
varsum
Variance sum.
-
Constructor Summary
Constructors Constructor Description KMeansProcessor(Relation<V> relation, NumberVectorDistance<? super V> distance, WritableIntegerDataStore assignment, double[] varsum)
Constructor.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description boolean
changed()
Get the "has changed" value.void
cleanup(Processor.Instance inst)
Invoke cleanup.double[][]
getMeans()
Get the new means.KMeansProcessor.Instance<V>
instantiate(Executor exectutor)
Create an instance.void
nextIteration(double[][] means)
Initialize for a new iteration.
-
-
-
Field Detail
-
relation
Relation<V extends NumberVector> relation
Data relation.
-
distance
NumberVectorDistance<? super V extends NumberVector> distance
Distance function.
-
assignment
WritableIntegerDataStore assignment
Assignment storage.
-
means
double[][] means
Mean vectors.
-
centroids
double[][] centroids
Updated cluster centroids
-
sizes
int[] sizes
(Partial) cluster sizes
-
varsum
double[] varsum
Variance sum.
-
changed
boolean changed
Whether the assignment changed during the last iteration.
-
-
Constructor Detail
-
KMeansProcessor
public KMeansProcessor(Relation<V> relation, NumberVectorDistance<? super V> distance, WritableIntegerDataStore assignment, double[] varsum)
Constructor.- Parameters:
relation
- Data relationdistance
- Distance functionassignment
- Cluster assignmentvarsum
- Variance sums
-
-
Method Detail
-
changed
public boolean changed()
Get the "has changed" value.- Returns:
- Changed flag.
-
nextIteration
public void nextIteration(double[][] means)
Initialize for a new iteration.- Parameters:
means
- New means.
-
instantiate
public KMeansProcessor.Instance<V> instantiate(Executor exectutor)
Description copied from interface:Processor
Create an instance. May be called multiple times, for example for multiple threads.- Specified by:
instantiate
in interfaceProcessor
- Parameters:
exectutor
- Job executor- Returns:
- Instance
-
cleanup
public void cleanup(Processor.Instance inst)
Description copied from interface:Processor
Invoke cleanup.
-
getMeans
public double[][] getMeans()
Get the new means.- Returns:
- New means
-
-