|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object comirva.audio.util.kmeans.KMeansClustering
public class KMeansClustering
This class implements a simple version of the k-Means Clustering
algorithm. A given list of points in a n-dimensional space will be grouped in
a specified number of clusters.
To measure the distance between two points in the n-dimensional space the
euclidian distance is used.
The clusters are initialized by randomly choosing one point of the given
point list for each cluster. Then the algorithm runs till there is no more
improvement to the mean quantization error (MQE).
InvalidClusteringException
,
PointList
Nested Class Summary | |
---|---|
protected class |
KMeansClustering.Cluster
A set of homogen points in the n-dimensional space is represented by a Cluster object. |
Field Summary | |
---|---|
protected KMeansClustering.Cluster[] |
clusters
|
protected Matrix[] |
covariances
|
protected PointList |
data
|
protected int |
dimension
|
protected boolean |
existsClustering
|
protected int |
maxIterations
|
protected boolean |
normalize
|
protected int |
numberClusters
|
protected static Random |
rnd
|
Constructor Summary | |
---|---|
KMeansClustering(int numberClusters,
PointList pl)
Constructs an object that allows to separate a point list into k clusters. |
|
KMeansClustering(int numberClusters,
PointList pl,
boolean normalize)
Constructs an object that allows to separate a point list into k clusters. |
|
KMeansClustering(int numberClusters,
PointList pl,
boolean normalize,
int maxIterations)
Constructs an object that allows to separate a point list into k clusters. |
Method Summary | |
---|---|
protected void |
createFullCovarianceMatrices()
Creats the full covariance matrices. |
double |
getClusterWeight(int cluster)
Returns the weight of the specified cluster. |
double[] |
getClusterWeights()
Returns the weights of all clusters in one array. |
Matrix |
getDiagCovarianceMatrix(int cluster)
Returns the diagonal covariance matrix of the specified cluster. |
Matrix[] |
getDiagCovariances()
Returns the diagonal covaraince matrices of all clusters in one array. |
Matrix |
getFullCovarianceMatrix(int cluster)
Returns the full covariance matrix of the specified cluster. |
Matrix[] |
getFullCovariances()
Returns the full covaraince matrices of all clusters in one array. |
Matrix |
getMean(int cluster)
Returns the mean of the specified cluster. |
Matrix[] |
getMeans()
Returns the mean vectors of all clusters in one array. |
int |
getNumberClusters()
Returns the number of clusters to separate the given data points into. |
void |
print()
For debugging purpose only. |
void |
run()
Starts the k-mean clustering algorithm. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
protected static Random rnd
protected int maxIterations
protected int numberClusters
protected int dimension
protected boolean normalize
protected PointList data
protected KMeansClustering.Cluster[] clusters
protected Matrix[] covariances
protected boolean existsClustering
Constructor Detail |
---|
public KMeansClustering(int numberClusters, PointList pl) throws IllegalArgumentException
numberClusters
- int number of clusters to separate the points intopl
- PointList a list of points in the n-dimensional space
IllegalArgumentException
- raised if method contract is violatedpublic KMeansClustering(int numberClusters, PointList pl, boolean normalize) throws IllegalArgumentException
numberClusters
- int number of clusters to separate the points intopl
- PointList a list of points in the n-dimensional spacenormalize
- boolean true if data-points should be normalized before
processing, otherwise false;
IllegalArgumentException
- raised if method contract is violatedpublic KMeansClustering(int numberClusters, PointList pl, boolean normalize, int maxIterations) throws IllegalArgumentException
numberClusters
- int number of clusters to separate the points intopl
- PointList a list of points in the n-dimensional spacenormalize
- boolean true if data-points should be normalized before
processing, otherwise false;maxIterations
- int maximal number of iterations the algorithm should
perform
IllegalArgumentException
- raised if method contract is violatedMethod Detail |
---|
public void run()
protected void createFullCovarianceMatrices()
public int getNumberClusters()
public Matrix getMean(int cluster)
run()
method.
cluster
- int the number of cluster to get the mean of
public Matrix[] getMeans()
run()
method.
public Matrix getFullCovarianceMatrix(int cluster)
run()
method.
cluster
- int the number of the cluster to get the covariance matrix of
public Matrix[] getFullCovariances()
run()
method.
public Matrix getDiagCovarianceMatrix(int cluster)
run()
method.
cluster
- int the number of the cluster to get the covariance matrix of
public Matrix[] getDiagCovariances()
run()
method.
public double getClusterWeight(int cluster)
run()
method.
cluster
- int the number of cluster to get the weight of
public double[] getClusterWeights()
run()
method.
public void print()
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |