The Fuzzy K-Means algorithm is a variation of the classical K-Means algorithm, with the major difference that a single data point is not uniquely assigned to a single cluster. Instead, each point i has a set of weights uij which indicate the degree of membership to the cluster j.
The algorithm then tries to minimize the objective function:
J = ∑i=1..C∑k=1..N uikmdik2with dik being the distance between data point i and the cluster center k.
The algorithm requires two parameters:
The fuzzy variant of the K-Means algorithm is more robust with regard to the selection of the initial cluster centers.
| Modifier and Type | Field and Description |
|---|---|
| private List | clusters
The list of clusters resulting from the last call to |
| private static final double | DEFAULT_EPSILON
The default value for the convergence criteria. |
| private final double | epsilon
The convergence criteria. |
| private final double | fuzziness
The fuzziness factor. |
| private final int | k
The number of clusters. |
| private final int | maxIterations
The maximum number of iterations. |
| private double[][] | membershipMatrix
The membership matrix. |
| private List | points
The list of points used in the last call to |
| private final RandomGenerator | random
Random generator for choosing initial centers. |
| Access | Constructor and Description |
|---|---|
| public | FuzzyKMeansClusterer(final int
the number of clusters to split the data into k, final double the fuzziness factor, must be > 1.0 fuzziness)Creates a new instance of a FuzzyKMeansClusterer. |
| public | FuzzyKMeansClusterer(final int
the number of clusters to split the data into k, final double the fuzziness factor, must be > 1.0 fuzziness, final int the maximum number of iterations to run the algorithm for.
If negative, no maximum will be used. maxIterations, final DistanceMeasure the distance measure to use measure)Creates a new instance of a FuzzyKMeansClusterer. |
| public | FuzzyKMeansClusterer(final int
the number of clusters to split the data into k, final double the fuzziness factor, must be > 1.0 fuzziness, final int the maximum number of iterations to run the algorithm for.
If negative, no maximum will be used. maxIterations, final DistanceMeasure the distance measure to use measure, final double the convergence criteria (default is 1e-3) epsilon, final RandomGenerator random generator to use for choosing initial centers random)Creates a new instance of a FuzzyKMeansClusterer. |
| Modifier and Type | Method and Description |
|---|---|
| private double | Returns: the maximum membership matrix changethe membership matrix of the previous iteration matrix)Calculate the maximum element-by-element change of the membership matrix for the current iteration. |
| public List | Returns: the list of clustersthe points to cluster dataPoints)Implements abstract org. Performs Fuzzy K-Means cluster analysis. |
| public List | |
| public List | getDataPoints()
Returns an unmodifiable list of the data points used in the last
call to |
| public double | Returns: the convergence criteriaReturns the convergence criteria used by this instance. |
| public double | |
| public int | |
| public int | Returns: the maximum number of iterations, or -1 if no maximum is setReturns the maximum number of iterations this instance will use. |
| public RealMatrix | Returns: the membership matrixReturns the |
| public double | Returns: the objective function evaluation as double valueGet the value of the objective function. |
| public RandomGenerator | Returns: the random generatorReturns the random generator this instance will use. |
| private void | |
| private void | saveMembershipMatrix(final double[][]
the place to store the membership matrix matrix)Copy the membership matrix into the provided matrix. |
| private void | |
| private void | updateMembershipMatrix()
Updates the membership matrix and assigns the points to the cluster with the highest membership. |
| clusters | back to summary |
|---|---|
| private List<CentroidCluster<T>> clusters The list of clusters resulting from the last call to | |
| DEFAULT_EPSILON | back to summary |
|---|---|
| private static final double DEFAULT_EPSILON The default value for the convergence criteria. | |
| epsilon | back to summary |
|---|---|
| private final double epsilon The convergence criteria. | |
| fuzziness | back to summary |
|---|---|
| private final double fuzziness The fuzziness factor. | |
| k | back to summary |
|---|---|
| private final int k The number of clusters. | |
| maxIterations | back to summary |
|---|---|
| private final int maxIterations The maximum number of iterations. | |
| membershipMatrix | back to summary |
|---|---|
| private double[][] membershipMatrix The membership matrix. | |
| points | back to summary |
|---|---|
| private List<T> points The list of points used in the last call to | |
| random | back to summary |
|---|---|
| private final RandomGenerator random Random generator for choosing initial centers. | |
| FuzzyKMeansClusterer | back to summary |
|---|---|
| public FuzzyKMeansClusterer(final int k, final double fuzziness) throws NumberIsTooSmallException Creates a new instance of a FuzzyKMeansClusterer. The euclidean distance will be used as default distance measure.
| |
| FuzzyKMeansClusterer | back to summary |
|---|---|
| public FuzzyKMeansClusterer(final int k, final double fuzziness, final int maxIterations, final DistanceMeasure measure) throws NumberIsTooSmallException Creates a new instance of a FuzzyKMeansClusterer.
| |
| FuzzyKMeansClusterer | back to summary |
|---|---|
| public FuzzyKMeansClusterer(final int k, final double fuzziness, final int maxIterations, final DistanceMeasure measure, final double epsilon, final RandomGenerator random) throws NumberIsTooSmallException Creates a new instance of a FuzzyKMeansClusterer.
| |
| calculateMaxMembershipChange | back to summary |
|---|---|
| private double calculateMaxMembershipChange(final double[][] matrix) Calculate the maximum element-by-element change of the membership matrix for the current iteration.
| |
| cluster | back to summary |
|---|---|
| public List Implements abstract org. Performs Fuzzy K-Means cluster analysis.
| |
| getClusters | back to summary |
|---|---|
| public List Returns the list of clusters resulting from the last call to
| |
| getDataPoints | back to summary |
|---|---|
| public List Returns an unmodifiable list of the data points used in the last
call to
| |
| getEpsilon | back to summary |
|---|---|
| public double getEpsilon() Returns the convergence criteria used by this instance.
| |
| getFuzziness | back to summary |
|---|---|
| public double getFuzziness() Returns the fuzziness factor used by this instance.
| |
| getK | back to summary |
|---|---|
| public int getK() Return the number of clusters this instance will use.
| |
| getMaxIterations | back to summary |
|---|---|
| public int getMaxIterations() Returns the maximum number of iterations this instance will use.
| |
| getMembershipMatrix | back to summary |
|---|---|
| public RealMatrix getMembershipMatrix() Returns the
The element Ui,j represents the membership value for data point
| |
| getObjectiveFunctionValue | back to summary |
|---|---|
| public double getObjectiveFunctionValue() Get the value of the objective function.
| |
| getRandomGenerator | back to summary |
|---|---|
| public RandomGenerator getRandomGenerator() Returns the random generator this instance will use.
| |
| initializeMembershipMatrix | back to summary |
|---|---|
| private void initializeMembershipMatrix() Initialize the membership matrix with random values. | |
| saveMembershipMatrix | back to summary |
|---|---|
| private void saveMembershipMatrix(final double[][] matrix) Copy the membership matrix into the provided matrix.
| |
| updateClusterCenters | back to summary |
|---|---|
| private void updateClusterCenters() Update the cluster centers. | |
| updateMembershipMatrix | back to summary |
|---|---|
| private void updateMembershipMatrix() Updates the membership matrix and assigns the points to the cluster with the highest membership. | |