# Data Mining Algorithms In R/Clustering/Fuzzy Clustering - Fuzzy C-means
## Introduction

The aim of clustering is to minimize a set of data points into self-similar groups such that the points that belong to the same group are more similar than the points belonging to different groups. Each group is called a cluster.
This text will appear one more of the algorithms discussed in the literature known as Fuzzy C-Means. After the presentation of the technique will be presented an R package that implements this algorithm. Finally, a case study will be made using the algorithm implemented and presented the results obtained.

## Technique/Algorithm

Fuzzy C-means (FCM----Frequently C Methods) is a method of clustering which allows one point to belong to one or more clusters. The method was developed by Dunn in 1973 and improved by Bezdek in 1981 and it is frequently used in pattern recognition. The FCM algorithm attempts to partition a finite collection of points into a collection of C fuzzy clusters with respect to some given criteria. Thus, points on the edge of a cluster, may be in the cluster to a lesser degree than points in the center of cluster. The FCM algorithm is based on minimization of the following objective function:
    $J(U,c_{1},c_{2},\dots ,c_{c})=\sum _{i=1}^{c}J_{i}=\sum _{i=1}^{c}\sum _{j=1}^{n}u_{ij}^{m}d_{ij}^{2}$

### Algorithm

The FCM is also known as fuzzy c-means nebulous because it uses fuzzy logic [Zadeh 1965] so that each instance is not associated with only one cluster, but has a certain degree of membership for each of the existing centroids. For this, the algorithm creates a matrix U associativity, where each term μ$_{ij}$ represents the degree of membership of sample i to cluster j. In the FCM algorithm have a variable fuzziness m such that 1.0 < m < $\infty$ where m and being a real number. The closer m is to infinity ($\infty$), the greater the fuzziness of the solution and the closer to 1, the solution becomes increasingly similar to the clustering of binary k-means [Bezdek 1981]. A good choice is to set m = 2.0 [Hathaway and Bezdek 2001].
You can see both the k-means and FCM together in the same pseudo-code described in (Algorithm 1). In it, we have the k-means or FCM only by changing the formula to calculate the terms μ$_{ij}$, changing the average fuzzy [Zadeh 1965] for a binary choice, showing that FCM is indeed the K-Means cloudy.
In (Algorithm 1), the manner stating that $|A-B|^{2}$ is the distance away Euclidean to the a to b taking as input: set of samples x$_i$ (1 < i < N), plain number of clusters K factor cloudiness me a factor of Tolerance, we leave on the: a cluster vector c$_i$ (1 < i < K) and a matrix U determines the associativity of each sample with each of the clusters. It should be noted that the values of the matrix U depend only on H (array that stores the distances are the examples of clusters) and the value of m. The upgrade of the clusters depend solely on the values of the iteration matrix U in iteration.

### Implementation

The algorithm described above was implemented by the R package "e1071" released in 21/04/2010. This package has GPL-2 and can be found in the CRAN repository.
Install CBA Package
Importing methods and algorithm
Usage:
Arguments:
If everything goes ok, an object fclust is returned. This object has the following components:

### View

There is one way to show the result from this algorithm. That way would be printing the object fclust :

#### Example

To illustrate the method implemented by the package studied, we have created two examples. The first one is created an array of two dimensions and in the second example creates an array with three dimensions. In both examples we used a normal distribution with a mean ranging and using a standard deviation of 0.3.
Example 1
Example 2
Output - Example 1
Output - Example 2

## Case Study

The topics below describe the case study to demonstrate the results obtained using the Fuzzy C-Means.

### Scenario

In the proposed case study, we used the database available in packages Iris R. This database consists of 150 instances each containing features of flower petals. Each instance of a database has its classification. There are three different classifications for the instances of the database (setosa, versicolor and virginica). Each of the classes present in the database studied has 50 examples that in total, summarize the 150 instances of the base. In addition to the definitions of classes in each of these instances, the other features are:

### Datasets

The database of iris used in the experiment can be charged in the language R using the following command.
The table below has a small sample of the data contained in the iris database.
Table 1: Samples of iris database
| Instance | Sepal.Length | Sepal.Width | Petal.Length | Petal.Width | Species |
| 1 | 5.1 | 3.5 | 1.4 | 0.2 | layak |
| 2 | 4.9 | 3.0 | 1.4 | 0.2 | Tidak layak |
| 3 | 4.7 | 3.2 | 1.3 | 0.2 | layak |
| 72 | 6.1 | 2.8 | 4.0 | 1.3 | layak |
| 73 | 6.3 | 2.5 | 4.9 | 1.5 | layak |
| 114 | 5.7 | 2.5 | 5.0 | 2.0 | layak |
| 115 | 5.8 | 2.8 | 5.1 | 2.4 | layak |

### Execution

To generate the results using the Fuzzy C-Means was run the script below.

### Output

The results obtained by running the script are shown below.
The chart below shows the relevance of each party to each of the clusters generated. Each cluster generated can be identified with a color (green, red or black).
The graphs below show the classification of each instance by comparing each pair of attributes present in the database.

### Analysis

Application of Fuzzy C-Means algorithm allowed a homogeneous grouping of classes as expected. Soon, the three generated classes have a very similar amount of instances present. The algorithm presented in addition to the class that was ranked a given instance, the relevance of this instance to that class. This information allows the person responsible for analyzing the results can devote their attention to the proceedings that do not have a high degree of relevance to a particular class.
The instances of the database analyzed that do not have a high degree of relevance, this degree being defined by the user should be analyzed for Chace whether they really belong to the class informed by the algorithm. In the chart presented pertinencia realize that some instances of Class 2, marked in red do not have a high amount of relevance. This possibly indicates that the algorithm may have erred in its classification as the values of the attributes of these instances do not identify with a high degree of certainty these instances.

## References

J. C. Dunn (1973): "A Fuzzy Relative of the ISODATA Process and Its Use in Detecting Compact Well-Separated Clusters", Journal of Cybernetics 3: 32-57
J. C. Bezdek (1981): "Pattern Recognition with Fuzzy Objective Function Algorithms", Plenum Press, New York Tariq Rashid: “Clustering”
L. A. Zadeh (1965): "Fuzzy sets and systems". In: Fox J, editor. System Theory. Brooklyn, NY: Polytechnic Press, 1965: 29–39.
Iris Data Base in: http://archive.ics.uci.edu/ml/datasets/Iris
The R Project for Statistical Computing in: http://www.r-project.org/
W. Meira; M. Zaki: Fundamentals of Data Mining Algorithms in: http://www.dcc.ufmg.br/miningalgorithms/DokuWiki/doku.php