V
- Vector typepublic class SameSizeKMeansAlgorithm<V extends NumberVector<?>> extends AbstractKMeans<V,DoubleDistance,MeanModel<V>>
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.
|
Modifier and Type | Field and Description |
---|---|
private static Logging |
LOG
Class logger
|
initializer, k, maxiter
distanceFunction
INIT_ID, K_ID, MAXITER_ID, SEED_ID
DISTANCE_FUNCTION_ID
Constructor and Description |
---|
SameSizeKMeansAlgorithm(PrimitiveDoubleDistanceFunction<? super NumberVector<?>> distanceFunction,
int k,
int maxiter,
KMeansInitialization<V> initializer)
Constructor.
|
Modifier and Type | Method and Description |
---|---|
protected Logging |
getLogger()
Get the (STATIC) logger for this class.
|
protected ArrayModifiableDBIDs |
initialAssignment(List<ModifiableDBIDs> clusters,
WritableDataStore<SameSizeKMeansAlgorithm.Meta> metas,
DBIDs ids) |
protected WritableDataStore<SameSizeKMeansAlgorithm.Meta> |
initializeMeta(Relation<V> relation,
List<? extends NumberVector<?>> means)
Initialize the metadata storage.
|
protected List<? extends NumberVector<?>> |
refineResult(Relation<V> relation,
List<? extends NumberVector<?>> means,
List<ModifiableDBIDs> clusters,
WritableDataStore<SameSizeKMeansAlgorithm.Meta> metas,
ArrayModifiableDBIDs tids)
Perform k-means style iterations to improve the clustering result.
|
Clustering<MeanModel<V>> |
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,
Integer dstnum)
Transfer a single element from one cluster to another.
|
protected void |
updateDistances(Relation<V> relation,
List<? extends NumberVector<?>> means,
WritableDataStore<SameSizeKMeansAlgorithm.Meta> metas,
PrimitiveDoubleDistanceFunction<NumberVector<?>> df)
Compute the distances of each object to all means.
|
assignToNearestCluster, getInputTypeRestriction, incrementalUpdateMean, macQueenIterate, means, medians, setDistanceFunction, setK, updateAssignment
getDistanceFunction
makeParameterDistanceFunction, run
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
run
getDistanceFunction
private static final Logging LOG
public SameSizeKMeansAlgorithm(PrimitiveDoubleDistanceFunction<? super NumberVector<?>> distanceFunction, int k, int maxiter, KMeansInitialization<V> initializer)
distanceFunction
- Distance functionk
- K parametermaxiter
- Maximum number of iterationsinitializer
- public Clustering<MeanModel<V>> run(Database database, Relation<V> relation)
database
- Databaserelation
- relation to useprotected WritableDataStore<SameSizeKMeansAlgorithm.Meta> initializeMeta(Relation<V> relation, List<? extends NumberVector<?>> means)
relation
- Relation to processmeans
- Mean vectorsprotected ArrayModifiableDBIDs initialAssignment(List<ModifiableDBIDs> clusters, WritableDataStore<SameSizeKMeansAlgorithm.Meta> metas, DBIDs ids)
protected void updateDistances(Relation<V> relation, List<? extends NumberVector<?>> means, WritableDataStore<SameSizeKMeansAlgorithm.Meta> metas, PrimitiveDoubleDistanceFunction<NumberVector<?>> df)
SameSizeKMeansAlgorithm.Meta.secondary
to point to the best cluster number except the
current cluster assignmentrelation
- Data relationmeans
- Meansmetas
- Metadata storagedf
- Distance functionprotected List<? extends NumberVector<?>> refineResult(Relation<V> relation, List<? extends NumberVector<?>> means, 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, Integer 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<V extends NumberVector<?>>>>