org.knime.base.node.mine.cluster.fuzzycmeans
Class FCMAlgorithm

java.lang.Object
  extended by org.knime.base.node.mine.cluster.fuzzycmeans.FCMAlgorithm
Direct Known Subclasses:
FCMAlgorithmMemory

public class FCMAlgorithm
extends Object

The Fuzzy c-means algorithm.

Author:
Nicolas Cebron, University of Konstanz

Constructor Summary
FCMAlgorithm(int nrClusters, double fuzzifier)
          Constructor for a Fuzzy c-means algorithm (with no noise detection).
FCMAlgorithm(int nrClusters, double fuzzifier, boolean calculateDelta, double deltalambda)
          Constructor for a Fuzzy c-means algorithm with noise detection.
 
Method Summary
protected  void addTotalChange(double change)
           
 double doOneIteration(ExecutionContext exec)
          Does one iteration in the Fuzzy c-means algorithm.
 double[][] getClusterCentres()
           
protected  double[][] getClusters()
           
protected  double getDelta()
           
protected  int getDimension()
           
protected  double getFuzzifier()
           
protected  double getLambda()
           
protected  int getNrClusters()
           
protected  int getNrRows()
           
protected  double getTotalChange()
           
 double[][] getweightMatrix()
           
protected  double[][] getWeightMatrix()
           
protected  int getWinner(double[] weights)
          Helper method to determine the winner cluster center (The cluster center to which the DataRow has the highest membership value).
 void init(DataTable table)
          An easier initialization, the rowcount and dimension are determined by iterating over the table.
 void init(int nrRows, int dimension, DataTable table)
          Inits the cluster centers and the weight matrix.
protected  boolean isCalculateDelta()
           
protected  boolean isNoise()
           
 boolean noiseClustering()
           
protected  void setClusterValue(int cluster, int column, double value)
          Sets a value in a cluster prototype.
protected  void setDelta(double delta)
           
protected  void setTotalChange(double value)
           
protected  void setWeightMatrixValue(int row, int column, double value)
          Sets a value in the weight matrix.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

FCMAlgorithm

public FCMAlgorithm(int nrClusters,
                    double fuzzifier)
Constructor for a Fuzzy c-means algorithm (with no noise detection).

Parameters:
nrClusters - the number of cluster prototypes to use
fuzzifier - allows the clusters to overlap

FCMAlgorithm

public FCMAlgorithm(int nrClusters,
                    double fuzzifier,
                    boolean calculateDelta,
                    double deltalambda)
Constructor for a Fuzzy c-means algorithm with noise detection. It can be indicated, whether the delta value of the noise cluster should be updated automatically or if it should be calculated automatically. The last parameter specifies either the delta value or the lambda value, depending on the boolean flag in the parameter before.

Parameters:
nrClusters - the number of clusters to use
fuzzifier - the fuzzifier, controls how much the clusters can overlap
calculateDelta - indicate whether delta should be calculated automatically
deltalambda - the delta value, if the previous parameter is false, the lambda value otherwise
Method Detail

init

public void init(int nrRows,
                 int dimension,
                 DataTable table)
Inits the cluster centers and the weight matrix. Must be called before the iterations are carried out.

Parameters:
nrRows - number of rows in the DataTable
dimension - the dimension of the table
table - the table to use.

init

public void init(DataTable table)
An easier initialization, the rowcount and dimension are determined by iterating over the table.

Parameters:
table - the table to use.

doOneIteration

public double doOneIteration(ExecutionContext exec)
                      throws CanceledExecutionException
Does one iteration in the Fuzzy c-means algorithm. First, the weight matrix is updated and then the cluster prototypes are recalculated.

Parameters:
exec - execution context to cancel the execution
Returns:
the total change in the cluster prototypes. Allows to decide whether the algorithm can be stopped.
Throws:
CanceledExecutionException - if the operation is canceled

getClusterCentres

public double[][] getClusterCentres()
Returns:
the cluster centres in a 2-dimensional double matrix

getweightMatrix

public double[][] getweightMatrix()
Returns:
the 2-dimensional weight matrix

noiseClustering

public boolean noiseClustering()
Returns:
flag indicating whether a noise clustering was performed

getWinner

protected final int getWinner(double[] weights)
Helper method to determine the winner cluster center (The cluster center to which the DataRow has the highest membership value).

Parameters:
weights - the weights.
Returns:
winner index.

getDimension

protected int getDimension()
Returns:
dimension of input space

getNrRows

protected int getNrRows()
Returns:
the number of Rows

getNrClusters

protected int getNrClusters()
Returns:
the number of clusters

getClusters

protected double[][] getClusters()
Returns:
the cluster prototypes

setClusterValue

protected void setClusterValue(int cluster,
                               int column,
                               double value)
Sets a value in a cluster prototype.

Parameters:
cluster - the cluster prototype
column - the column
value - the value to set.

getWeightMatrix

protected double[][] getWeightMatrix()
Returns:
the weight matrix.

setWeightMatrixValue

protected void setWeightMatrixValue(int row,
                                    int column,
                                    double value)
Sets a value in the weight matrix.

Parameters:
row - the row.
column - the column.
value - the value to set.

getFuzzifier

protected double getFuzzifier()
Returns:
the fuzzifier.

isNoise

protected boolean isNoise()
Returns:
noise clustering.

isCalculateDelta

protected boolean isCalculateDelta()
Returns:
is delta calculated.

getDelta

protected double getDelta()
Returns:
delta value

setDelta

protected void setDelta(double delta)
Parameters:
delta - new delta value.

getLambda

protected double getLambda()
Returns:
lambda value.

getTotalChange

protected double getTotalChange()
Returns:
total change in prototypes.

addTotalChange

protected void addTotalChange(double change)
Parameters:
change - current change in prototypes to sum up.

setTotalChange

protected void setTotalChange(double value)
Parameters:
value - ne wvalue for total change in prototypes.


Copyright, 2003 - 2010. All rights reserved.
University of Konstanz, Germany.
Chair for Bioinformatics and Information Mining, Prof. Dr. Michael R. Berthold.
You may not modify, publish, transmit, transfer or sell, reproduce, create derivative works from, distribute, perform, display, or in any way exploit any of the content, in whole or in part, except as otherwise expressly permitted in writing by the copyright owner or as specified in the license file distributed with this product.