jminhep.algorithms
Class FuzzyCMeansAlg
- java.lang.Object
-
- jminhep.algorithms.FuzzyCMeansAlg
-
public class FuzzyCMeansAlg extends java.lang.ObjectFuzzy C-means cluster algorithm. Look at details in: http://home.dei.polimi.it/matteucc/Clustering/tutorial_html/cmeans.html
-
-
Constructor Summary
Constructors Constructor and Description FuzzyCMeansAlg(DataHolder data)Initialize Fuzzy C-means calculations
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method and Description voiddelete()Clearint[]getAssignments()Returns cluster assignments of all points.DataHoldergetCenters()Returns cluster centersintgetClusters()Get the number of clustersdoublegetCompactness()This method returns the Compactness and Separation measure of cluster validity (see Fuzzy Algorithms With Applications to Image Processing and Pattern Recognition, Zheru Chi, Hong Yan, Tuan Pham, World Scientific, pp.intgetError()Get error code.double[][]getMembeship()Return cluster membershipjava.lang.StringgetName()Get the description of the algorithmint[]getNumberPoints()Returns the number of points in each cluster.doublegetPartitionCoefficient()This method returns the Partition Coefficient measure of cluster validity (see Fuzzy Algorithms With Applications to Image Processing and Pattern Recognition, Zheru Chi, Hong Yan, Tuan Pham, World Scientific, pp.doublegetPartitionEntropy()This method returns the Partition Entropy measure of cluster validity (see Fuzzy Algorithms With Applications to Image Processing and Pattern Recognition, Zheru Chi, Hong Yan, Tuan Pham, World Scientific, pp.longgetPosition()This method returns a measure of the progress of the algorithm.longgetSize()This method returns the estimated size (steps) for this task.booleanisFinished()This method returns true if the clustering has finished.voidrun()Run classic Fuzzy C-Means clustering algorithm: Calculate the cluster centers.voidrunBest()Runs for the best estimatevoidsetClusters(int N)Set number of clusters for calculations.voidsetOptions(int maxIterations, double epsilon, double fuzziness)Set initial conditions for clustering.voidsetProb(double probClusters)Set probability of associations with each cluster.
-
-
-
Constructor Detail
-
FuzzyCMeansAlg
public FuzzyCMeansAlg(DataHolder data)
Initialize Fuzzy C-means calculations- Parameters:
d- input data
-
-
Method Detail
-
setClusters
public void setClusters(int N)
Set number of clusters for calculations.- Parameters:
numClusters- Set the desired number of clusters.
-
getClusters
public int getClusters()
Get the number of clusters- Returns:
- number of clusters
-
getMembeship
public double[][] getMembeship()
Return cluster membership- Returns:
- membership matrix (2D)
-
setOptions
public void setOptions(int maxIterations, double epsilon, double fuzziness)Set initial conditions for clustering.- Parameters:
maxIterations- the maximum number of iterations.fuzziness- the fuzziness (a.k.a. the "m" value)epsilon- a small value used to verify if clustering has converged.
-
delete
public void delete()
Clear
-
setProb
public void setProb(double probClusters)
Set probability of associations with each cluster. The default value is 0.68. Does dot affect calculations.- Parameters:
probClusters- probability association.
-
getCenters
public DataHolder getCenters()
Returns cluster centers- Returns:
- DataHolder with cluster centers
-
getAssignments
public int[] getAssignments()
Returns cluster assignments of all points. Affected by the method setProb(), which sets association probability (default is 0.68).- Returns:
- array with cluster assignments
-
getNumberPoints
public int[] getNumberPoints()
Returns the number of points in each cluster. Affected by the method setProb(), which sets association probability (default is 0.68). Look also at getAssignment() and getMembership()- Returns:
- number of points in each cluster
-
runBest
public void runBest()
Runs for the best estimate
-
run
public void run()
Run classic Fuzzy C-Means clustering algorithm: Calculate the cluster centers. Update the membership function. Calculate statistics and repeat from 1 if needed.
-
getSize
public long getSize()
This method returns the estimated size (steps) for this task. The value is, of course, an approximation, just so we will be able to give the user a feedback on the processing time. In this case, the value is calculated as the number of loops in the run() method.
-
getPosition
public long getPosition()
This method returns a measure of the progress of the algorithm.
-
isFinished
public boolean isFinished()
This method returns true if the clustering has finished.
-
getPartitionCoefficient
public double getPartitionCoefficient()
This method returns the Partition Coefficient measure of cluster validity (see Fuzzy Algorithms With Applications to Image Processing and Pattern Recognition, Zheru Chi, Hong Yan, Tuan Pham, World Scientific, pp. 91)
-
getPartitionEntropy
public double getPartitionEntropy()
This method returns the Partition Entropy measure of cluster validity (see Fuzzy Algorithms With Applications to Image Processing and Pattern Recognition, Zheru Chi, Hong Yan, Tuan Pham, World Scientific, pp. 91)
-
getError
public int getError()
Get error code.- Returns:
- if 0, clustering looks OK
-
getCompactness
public double getCompactness()
This method returns the Compactness and Separation measure of cluster validity (see Fuzzy Algorithms With Applications to Image Processing and Pattern Recognition, Zheru Chi, Hong Yan, Tuan Pham, World Scientific, pp. 93)
-
getName
public java.lang.String getName()
Get the description of the algorithm- Returns:
- algorithm description
-
-
DMelt 3.0 © DataMelt by jWork.ORG