|
|
|||||||||||||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||||||||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||||||||||||||
java.lang.Objectde.lmu.ifi.dbs.elki.logging.AbstractLoggable
de.lmu.ifi.dbs.elki.utilities.optionhandling.AbstractParameterizable
de.lmu.ifi.dbs.elki.algorithm.AbstractAlgorithm<O,R>
de.lmu.ifi.dbs.elki.algorithm.DistanceBasedAlgorithm<V,D,Clustering<Model>>
de.lmu.ifi.dbs.elki.algorithm.clustering.KMeans<D,V>
D - a type of Distance as returned by the used distance functionV - a type of RealVector as a suitable datatype for this algorithmpublic class KMeans<D extends Distance<D>,V extends RealVector<V,?>>
Provides the k-means algorithm.
Reference:
J. McQueen: Some Methods for Classification and Analysis of Multivariate Observations.
In 5th Berkeley Symp. Math. Statist. Prob., Vol. 1, 1967, pp 281-297.
| Field Summary | |
|---|---|
private int |
k
Holds the value of K_PARAM. |
static OptionID |
K_ID
OptionID for K_PARAM |
private IntParameter |
K_PARAM
Parameter to specify the number of clusters to find, must be an integer greater than 0. |
private Clustering<Model> |
result
Keeps the result. |
| Fields inherited from class de.lmu.ifi.dbs.elki.algorithm.DistanceBasedAlgorithm |
|---|
DISTANCE_FUNCTION_ID, DISTANCE_FUNCTION_PARAM |
| Fields inherited from class de.lmu.ifi.dbs.elki.utilities.optionhandling.AbstractParameterizable |
|---|
optionHandler |
| Fields inherited from class de.lmu.ifi.dbs.elki.logging.AbstractLoggable |
|---|
debug, logger |
| Constructor Summary | |
|---|---|
KMeans()
Provides the k-means algorithm, adding parameter K_PARAM
to the option handler
additionally to parameters of super class. |
|
| Method Summary | |
|---|---|
Description |
getDescription()
Returns a description of the algorithm. |
Clustering<Model> |
getResult()
Retrieve the result. |
protected List<V> |
means(List<List<Integer>> clusters,
List<V> means,
Database<V> database)
Returns the mean vectors of the given clusters in the given database. |
protected Clustering<Model> |
runInTime(Database<V> database)
Performs the k-means algorithm on the given database. |
List<String> |
setParameters(List<String> args)
Calls the super method and sets additionally the value of the parameter K_PARAM. |
protected List<List<Integer>> |
sort(List<V> means,
Database<V> database)
Returns a list of clusters. |
| Methods inherited from class de.lmu.ifi.dbs.elki.algorithm.DistanceBasedAlgorithm |
|---|
getDistanceFunction |
| Methods inherited from class de.lmu.ifi.dbs.elki.algorithm.AbstractAlgorithm |
|---|
isTime, isVerbose, run, setTime, setVerbose |
| Methods inherited from class de.lmu.ifi.dbs.elki.utilities.optionhandling.AbstractParameterizable |
|---|
addOption, addParameterizable, addParameterizable, checkGlobalParameterConstraints, collectOptions, getAttributeSettings, getParameters, rememberParametersExcept, removeOption, removeParameterizable, shortDescription |
| Methods inherited from class de.lmu.ifi.dbs.elki.logging.AbstractLoggable |
|---|
debugFine, debugFiner, debugFinest, exception, progress, verbose, warning |
| 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 |
| Methods inherited from interface de.lmu.ifi.dbs.elki.algorithm.Algorithm |
|---|
setTime, setVerbose |
| Methods inherited from interface de.lmu.ifi.dbs.elki.utilities.optionhandling.Parameterizable |
|---|
checkGlobalParameterConstraints, collectOptions, getParameters, shortDescription |
| Field Detail |
|---|
public static final OptionID K_ID
K_PARAM
private final IntParameter K_PARAM
Key: -kmeans.k
private int k
K_PARAM.
private Clustering<Model> result
| Constructor Detail |
|---|
public KMeans()
K_PARAM
to the option handler
additionally to parameters of super class.
| Method Detail |
|---|
public Description getDescription()
Algorithm
getDescription in interface Algorithm<V extends RealVector<V,?>,Clustering<Model>>public Clustering<Model> getResult()
ClusteringAlgorithm
getResult in interface Algorithm<V extends RealVector<V,?>,Clustering<Model>>getResult in interface ClusteringAlgorithm<Clustering<Model>,V extends RealVector<V,?>>
protected Clustering<Model> runInTime(Database<V> database)
throws IllegalStateException
runInTime in class AbstractAlgorithm<V extends RealVector<V,?>,Clustering<Model>>database - the database to run the algorithm on
IllegalStateException - if the algorithm has not been initialized
properly (e.g. the setParameters(String[]) method has been failed
to be called).
protected List<V> means(List<List<Integer>> clusters,
List<V> means,
Database<V> database)
clusters - the clusters to compute the meansmeans - the recent meansdatabase - the database containing the vectors
protected List<List<Integer>> sort(List<V> means,
Database<V> database)
means - a list of k meansdatabase - the database to cluster
public List<String> setParameters(List<String> args)
throws ParameterException
K_PARAM.
setParameters in interface ParameterizablesetParameters in class DistanceBasedAlgorithm<V extends RealVector<V,?>,D extends Distance<D>,Clustering<Model>>args - parameters to set the attributes accordingly to
ParameterException - in case of wrong parameter-setting
|
|
|||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||||