|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object de.lmu.ifi.dbs.elki.algorithm.AbstractAlgorithm<R> de.lmu.ifi.dbs.elki.algorithm.AbstractPrimitiveDistanceBasedAlgorithm<V,D,Clustering<MeanModel<V>>> de.lmu.ifi.dbs.elki.algorithm.clustering.KMeans<V,D>
D
- a type of Distance
as returned by the used distance
functionV
- a type of NumberVector
as a suitable datatype for this
algorithm@Title(value="K-Means") @Description(value="Finds a partitioning into k clusters.") @Reference(authors="J. MacQueen", title="Some Methods for Classification and Analysis of Multivariate Observations", booktitle="5th Berkeley Symp. Math. Statist. Prob., Vol. 1, 1967, pp 281-297", url="http://projecteuclid.org/euclid.bsmsp/1200512992") public class KMeans<V extends NumberVector<V,?>,D extends Distance<D>>
Provides the k-means algorithm.
Reference: J. MacQueen: Some Methods for Classification and Analysis of
Multivariate Observations.
In 5th Berkeley Symp. Math. Statist. Prob., Vol. 1, 1967, pp 281-297.
Nested Class Summary | |
---|---|
static class |
KMeans.Parameterizer<V extends NumberVector<V,?>,D extends Distance<D>>
Parameterization class. |
Field Summary | |
---|---|
private int |
k
Holds the value of K_ID . |
static OptionID |
K_ID
Parameter to specify the number of clusters to find, must be an integer greater than 0. |
private static Logging |
logger
The logger for this class. |
private int |
maxiter
Holds the value of MAXITER_ID . |
static OptionID |
MAXITER_ID
Parameter to specify the number of clusters to find, must be an integer greater or equal to 0, where 0 means no limit. |
private Long |
seed
Holds the value of SEED_ID . |
static OptionID |
SEED_ID
Parameter to specify the random generator seed. |
Constructor Summary | |
---|---|
KMeans(PrimitiveDistanceFunction<? super V,D> distanceFunction,
int k,
int maxiter,
Long seed)
Constructor. |
Method Summary | |
---|---|
TypeInformation[] |
getInputTypeRestriction()
Get the input type restriction used for negotiating the data query. |
protected Logging |
getLogger()
Get the (STATIC) logger for this class. |
protected List<V> |
means(List<? extends ModifiableDBIDs> clusters,
List<V> means,
Relation<V> database)
Returns the mean vectors of the given clusters in the given database. |
Clustering<MeanModel<V>> |
run(Database database,
Relation<V> relation)
Run k-means |
protected List<? extends ModifiableDBIDs> |
sort(List<V> means,
Relation<V> database)
Returns a list of clusters. |
Methods inherited from class de.lmu.ifi.dbs.elki.algorithm.AbstractPrimitiveDistanceBasedAlgorithm |
---|
getDistanceFunction |
Methods inherited from class de.lmu.ifi.dbs.elki.algorithm.AbstractAlgorithm |
---|
makeParameterDistanceFunction, run |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Methods inherited from interface de.lmu.ifi.dbs.elki.algorithm.clustering.ClusteringAlgorithm |
---|
run |
Field Detail |
---|
private static final Logging logger
public static final OptionID K_ID
public static final OptionID MAXITER_ID
public static final OptionID SEED_ID
private int k
K_ID
.
private int maxiter
MAXITER_ID
.
private Long seed
SEED_ID
.
Constructor Detail |
---|
public KMeans(PrimitiveDistanceFunction<? super V,D> distanceFunction, int k, int maxiter, Long seed)
distanceFunction
- distance functionk
- k parametermaxiter
- Maxiter parameterseed
- Random generator seedMethod Detail |
---|
public Clustering<MeanModel<V>> run(Database database, Relation<V> relation) throws IllegalStateException
database
- Databaserelation
- relation to use
IllegalStateException
protected List<V> means(List<? extends ModifiableDBIDs> clusters, List<V> means, Relation<V> database)
clusters
- the clusters to compute the meansmeans
- the recent meansdatabase
- the database containing the vectors
protected List<? extends ModifiableDBIDs> sort(List<V> means, Relation<V> database)
means
- a list of k meansdatabase
- the database to cluster
public TypeInformation[] getInputTypeRestriction()
AbstractAlgorithm
getInputTypeRestriction
in interface Algorithm
getInputTypeRestriction
in class AbstractAlgorithm<Clustering<MeanModel<V extends NumberVector<V,?>>>>
protected Logging getLogger()
AbstractAlgorithm
getLogger
in class AbstractAlgorithm<Clustering<MeanModel<V extends NumberVector<V,?>>>>
|
|
|||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |