V
- Vector typepublic class SameSizeKMeansAlgorithm<V extends NumberVector> extends AbstractKMeans<V,MeanModel>
Note that this is a rather obvious variation, and one cannot expect very good results from this algorithm. K-means already is quite primitive, and putting in the size constraint will likely not make the results much better (in particular, it will even less be able to make sense of outliers!)
There is no reference for this algorithm. If you want to cite it, please cite the latest ELKI release as given on the ELKI web page: https://elki-project.github.io/publications
Modifier and Type | Class and Description |
---|---|
private class |
SameSizeKMeansAlgorithm.Meta
Object metadata.
|
static class |
SameSizeKMeansAlgorithm.Parameterizer<V extends NumberVector>
Parameterization class.
|
class |
SameSizeKMeansAlgorithm.PreferenceComparator
Sort a list of integers (= cluster numbers) by the distances.
|
AbstractKMeans.Instance
Modifier and Type | Field and Description |
---|---|
private static Logging |
LOG
Class logger
|
initializer, k, maxiter
distanceFunction
ALGORITHM_ID
INIT_ID, K_ID, MAXITER_ID, SEED_ID, VARSTAT_ID
DISTANCE_FUNCTION_ID
Constructor and Description |
---|
SameSizeKMeansAlgorithm(NumberVectorDistanceFunction<? super V> distanceFunction,
int k,
int maxiter,
KMeansInitialization initializer)
Constructor.
|
Modifier and Type | Method and Description |
---|---|
protected Logging |
getLogger()
Get the (STATIC) logger for this class.
|
protected ArrayModifiableDBIDs |
initialAssignment(java.util.List<ModifiableDBIDs> clusters,
WritableDataStore<SameSizeKMeansAlgorithm.Meta> metas,
DBIDs ids) |
protected WritableDataStore<SameSizeKMeansAlgorithm.Meta> |
initializeMeta(Relation<V> relation,
double[][] means)
Initialize the metadata storage.
|
protected double[][] |
refineResult(Relation<V> relation,
double[][] means,
java.util.List<ModifiableDBIDs> clusters,
WritableDataStore<SameSizeKMeansAlgorithm.Meta> metas,
ArrayModifiableDBIDs tids)
Perform k-means style iterations to improve the clustering result.
|
Clustering<MeanModel> |
run(Database database,
Relation<V> relation)
Run k-means with cluster size constraints.
|
protected void |
transfer(WritableDataStore<SameSizeKMeansAlgorithm.Meta> metas,
SameSizeKMeansAlgorithm.Meta meta,
ModifiableDBIDs src,
ModifiableDBIDs dst,
DBIDRef id,
int dstnum)
Transfer a single element from one cluster to another.
|
protected void |
updateDistances(Relation<V> relation,
double[][] means,
WritableDataStore<SameSizeKMeansAlgorithm.Meta> metas,
NumberVectorDistanceFunction<? super V> df)
Compute the distances of each object to all means.
|
getInputTypeRestriction, incrementalUpdateMean, initialMeans, means, minusEquals, nearestMeans, plusEquals, plusMinusEquals, setDistanceFunction, setInitializer, setK
getDistanceFunction
run
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
run
getDistanceFunction
private static final Logging LOG
public SameSizeKMeansAlgorithm(NumberVectorDistanceFunction<? super V> distanceFunction, int k, int maxiter, KMeansInitialization initializer)
distanceFunction
- Distance functionk
- K parametermaxiter
- Maximum number of iterationsinitializer
- public Clustering<MeanModel> run(Database database, Relation<V> relation)
database
- Databaserelation
- relation to useprotected WritableDataStore<SameSizeKMeansAlgorithm.Meta> initializeMeta(Relation<V> relation, double[][] means)
relation
- Relation to processmeans
- Mean vectorsprotected ArrayModifiableDBIDs initialAssignment(java.util.List<ModifiableDBIDs> clusters, WritableDataStore<SameSizeKMeansAlgorithm.Meta> metas, DBIDs ids)
protected void updateDistances(Relation<V> relation, double[][] means, WritableDataStore<SameSizeKMeansAlgorithm.Meta> metas, NumberVectorDistanceFunction<? super V> df)
SameSizeKMeansAlgorithm.Meta.secondary
to point to the best cluster number except the
current cluster assignmentrelation
- Data relationmeans
- Meansmetas
- Metadata storagedf
- Distance functionprotected double[][] refineResult(Relation<V> relation, double[][] means, java.util.List<ModifiableDBIDs> clusters, WritableDataStore<SameSizeKMeansAlgorithm.Meta> metas, ArrayModifiableDBIDs tids)
relation
- Data relationmeans
- Means listclusters
- Cluster listmetas
- Metadata storagetids
- DBIDs arrayprotected void transfer(WritableDataStore<SameSizeKMeansAlgorithm.Meta> metas, SameSizeKMeansAlgorithm.Meta meta, ModifiableDBIDs src, ModifiableDBIDs dst, DBIDRef id, int dstnum)
metas
- Meta storagemeta
- Meta of current objectsrc
- Source clusterdst
- Destination clusterid
- Object IDdstnum
- Destination cluster numberprotected Logging getLogger()
AbstractAlgorithm
getLogger
in class AbstractAlgorithm<Clustering<MeanModel>>
Copyright © 2019 ELKI Development Team. License information.