
V - vector datatypeD - distance value typepublic class KMeansBatchedLloyd<V extends NumberVector<?>,D extends Distance<D>> extends AbstractKMeans<V,D,KMeansModel<V>>
| Modifier and Type | Class and Description |
|---|---|
static class |
KMeansBatchedLloyd.Parameterizer<V extends NumberVector<?>,D extends Distance<D>>
Parameterization class.
|
| Modifier and Type | Field and Description |
|---|---|
(package private) int |
blocks
Number of blocks to use.
|
private static Logging |
LOG
The logger for this class.
|
(package private) RandomFactory |
random
Random used for partitioning.
|
initializer, k, maxiterdistanceFunctionINIT_ID, K_ID, MAXITER_ID, SEED_IDDISTANCE_FUNCTION_ID| Constructor and Description |
|---|
KMeansBatchedLloyd(PrimitiveDistanceFunction<NumberVector<?>,D> distanceFunction,
int k,
int maxiter,
KMeansInitialization<V> initializer,
int blocks,
RandomFactory random)
Constructor.
|
| Modifier and Type | Method and Description |
|---|---|
protected boolean |
assignToNearestCluster(Relation<V> relation,
DBIDs ids,
List<? extends NumberVector<?>> oldmeans,
double[][] meanshift,
int[] changesize,
List<? extends ModifiableDBIDs> clusters,
WritableIntegerDataStore assignment)
Returns a list of clusters.
|
protected Logging |
getLogger()
Get the (STATIC) logger for this class.
|
Clustering<KMeansModel<V>> |
run(Database database,
Relation<V> relation)
Run the clustering algorithm.
|
protected boolean |
updateAssignment(DBIDIter id,
V fv,
List<? extends ModifiableDBIDs> clusters,
WritableIntegerDataStore assignment,
double[][] meanshift,
int[] changesize,
int minIndex)
Update the assignment of a single object.
|
protected void |
updateMeans(List<Vector> means,
double[][] meanshift,
List<ModifiableDBIDs> clusters,
int[] changesize)
Merge changes into mean vectors.
|
assignToNearestCluster, getInputTypeRestriction, incrementalUpdateMean, macQueenIterate, means, medians, setDistanceFunction, setK, updateAssignmentgetDistanceFunctionmakeParameterDistanceFunction, runclone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitrungetDistanceFunctionprivate static final Logging LOG
int blocks
RandomFactory random
public KMeansBatchedLloyd(PrimitiveDistanceFunction<NumberVector<?>,D> distanceFunction, int k, int maxiter, KMeansInitialization<V> initializer, int blocks, RandomFactory random)
distanceFunction - distance functionk - k parametermaxiter - Maxiter parameterinitializer - Initialization methodblocks - Number of blocksrandom - Random factory used for partitioning.public Clustering<KMeansModel<V>> run(Database database, Relation<V> relation)
KMeansdatabase - Database to run on.relation - Relation to process.protected boolean assignToNearestCluster(Relation<V> relation, DBIDs ids, List<? extends NumberVector<?>> oldmeans, double[][] meanshift, int[] changesize, List<? extends ModifiableDBIDs> clusters, WritableIntegerDataStore assignment)
relation - the database to clusterids - IDs to processoldmeans - a list of k meansmeanshift - delta to apply to each meanchangesize - New cluster sizesclusters - cluster assignmentassignment - Current cluster assignmentprotected boolean updateAssignment(DBIDIter id, V fv, List<? extends ModifiableDBIDs> clusters, WritableIntegerDataStore assignment, double[][] meanshift, int[] changesize, int minIndex)
id - Object to assignfv - Vectorclusters - Clustersassignment - Current cluster assignmentmeanshift - Current shifting offsetchangesize - Size change of the current clusterminIndex - Index of best cluster.true when assignment changed.protected void updateMeans(List<Vector> means, double[][] meanshift, List<ModifiableDBIDs> clusters, int[] changesize)
means - Mean vectorsmeanshift - Shift offsetclusters - changesize - Size of change (for weighting!)protected Logging getLogger()
AbstractAlgorithmgetLogger in class AbstractAlgorithm<Clustering<KMeansModel<V extends NumberVector<?>>>>