Partitioning Cluster Analysis Using Fuzzy C-Means

PREPARING FOR THE ANALYSIS


Install and load the package ppclust

This vignette is designed to be used with the ppclust package. You can download the recent version of the package ‘ppclust’ from CRAN with the following command:

install.packages("ppclust")

If you have already installed ‘ppclust’, you can load it into R working environment by using the following command:

library(ppclust)

Load the required packages

For visualization of the clustering results, some examples in this vignette use the functions from some cluster analysis packages such as ‘cluster’, ‘fclust’ and ‘factoextra’. Therefore, these packages should be loaded into R working environment with the following commands:

library(factoextra)
library(cluster)
library(fclust)

Load the data set

We demonstrate FCM on the Iris data set (Anderson, 1935). It is a real data set of the four features (Sepal.Length, Sepal.Width, Petal.Length and Petal.Width) of 150 iris flowers with three species (in the last column as the class variable). This four-dimensional data set contains 50 samples each of three iris species. One of these three natural clusters (Class 1) is linearly well-separated from the other two clusters, while Classes 2 and 3 have some overlap as seen in the plot below.

data(iris)
x=iris[,-5]
x
##     Sepal.Length Sepal.Width Petal.Length Petal.Width
## 1            5.1         3.5          1.4         0.2
## 2            4.9         3.0          1.4         0.2
## 3            4.7         3.2          1.3         0.2
## 4            4.6         3.1          1.5         0.2
## 5            5.0         3.6          1.4         0.2
## 6            5.4         3.9          1.7         0.4
## 7            4.6         3.4          1.4         0.3
## 8            5.0         3.4          1.5         0.2
## 9            4.4         2.9          1.4         0.2
## 10           4.9         3.1          1.5         0.1
## 11           5.4         3.7          1.5         0.2
## 12           4.8         3.4          1.6         0.2
## 13           4.8         3.0          1.4         0.1
## 14           4.3         3.0          1.1         0.1
## 15           5.8         4.0          1.2         0.2
## 16           5.7         4.4          1.5         0.4
## 17           5.4         3.9          1.3         0.4
## 18           5.1         3.5          1.4         0.3
## 19           5.7         3.8          1.7         0.3
## 20           5.1         3.8          1.5         0.3
## 21           5.4         3.4          1.7         0.2
## 22           5.1         3.7          1.5         0.4
## 23           4.6         3.6          1.0         0.2
## 24           5.1         3.3          1.7         0.5
## 25           4.8         3.4          1.9         0.2
## 26           5.0         3.0          1.6         0.2
## 27           5.0         3.4          1.6         0.4
## 28           5.2         3.5          1.5         0.2
## 29           5.2         3.4          1.4         0.2
## 30           4.7         3.2          1.6         0.2
## 31           4.8         3.1          1.6         0.2
## 32           5.4         3.4          1.5         0.4
## 33           5.2         4.1          1.5         0.1
## 34           5.5         4.2          1.4         0.2
## 35           4.9         3.1          1.5         0.2
## 36           5.0         3.2          1.2         0.2
## 37           5.5         3.5          1.3         0.2
## 38           4.9         3.6          1.4         0.1
## 39           4.4         3.0          1.3         0.2
## 40           5.1         3.4          1.5         0.2
## 41           5.0         3.5          1.3         0.3
## 42           4.5         2.3          1.3         0.3
## 43           4.4         3.2          1.3         0.2
## 44           5.0         3.5          1.6         0.6
## 45           5.1         3.8          1.9         0.4
## 46           4.8         3.0          1.4         0.3
## 47           5.1         3.8          1.6         0.2
## 48           4.6         3.2          1.4         0.2
## 49           5.3         3.7          1.5         0.2
## 50           5.0         3.3          1.4         0.2
## 51           7.0         3.2          4.7         1.4
## 52           6.4         3.2          4.5         1.5
## 53           6.9         3.1          4.9         1.5
## 54           5.5         2.3          4.0         1.3
## 55           6.5         2.8          4.6         1.5
## 56           5.7         2.8          4.5         1.3
## 57           6.3         3.3          4.7         1.6
## 58           4.9         2.4          3.3         1.0
## 59           6.6         2.9          4.6         1.3
## 60           5.2         2.7          3.9         1.4
## 61           5.0         2.0          3.5         1.0
## 62           5.9         3.0          4.2         1.5
## 63           6.0         2.2          4.0         1.0
## 64           6.1         2.9          4.7         1.4
## 65           5.6         2.9          3.6         1.3
## 66           6.7         3.1          4.4         1.4
## 67           5.6         3.0          4.5         1.5
## 68           5.8         2.7          4.1         1.0
## 69           6.2         2.2          4.5         1.5
## 70           5.6         2.5          3.9         1.1
## 71           5.9         3.2          4.8         1.8
## 72           6.1         2.8          4.0         1.3
## 73           6.3         2.5          4.9         1.5
## 74           6.1         2.8          4.7         1.2
## 75           6.4         2.9          4.3         1.3
## 76           6.6         3.0          4.4         1.4
## 77           6.8         2.8          4.8         1.4
## 78           6.7         3.0          5.0         1.7
## 79           6.0         2.9          4.5         1.5
## 80           5.7         2.6          3.5         1.0
## 81           5.5         2.4          3.8         1.1
## 82           5.5         2.4          3.7         1.0
## 83           5.8         2.7          3.9         1.2
## 84           6.0         2.7          5.1         1.6
## 85           5.4         3.0          4.5         1.5
## 86           6.0         3.4          4.5         1.6
## 87           6.7         3.1          4.7         1.5
## 88           6.3         2.3          4.4         1.3
## 89           5.6         3.0          4.1         1.3
## 90           5.5         2.5          4.0         1.3
## 91           5.5         2.6          4.4         1.2
## 92           6.1         3.0          4.6         1.4
## 93           5.8         2.6          4.0         1.2
## 94           5.0         2.3          3.3         1.0
## 95           5.6         2.7          4.2         1.3
## 96           5.7         3.0          4.2         1.2
## 97           5.7         2.9          4.2         1.3
## 98           6.2         2.9          4.3         1.3
## 99           5.1         2.5          3.0         1.1
## 100          5.7         2.8          4.1         1.3
## 101          6.3         3.3          6.0         2.5
## 102          5.8         2.7          5.1         1.9
## 103          7.1         3.0          5.9         2.1
## 104          6.3         2.9          5.6         1.8
## 105          6.5         3.0          5.8         2.2
## 106          7.6         3.0          6.6         2.1
## 107          4.9         2.5          4.5         1.7
## 108          7.3         2.9          6.3         1.8
## 109          6.7         2.5          5.8         1.8
## 110          7.2         3.6          6.1         2.5
## 111          6.5         3.2          5.1         2.0
## 112          6.4         2.7          5.3         1.9
## 113          6.8         3.0          5.5         2.1
## 114          5.7         2.5          5.0         2.0
## 115          5.8         2.8          5.1         2.4
## 116          6.4         3.2          5.3         2.3
## 117          6.5         3.0          5.5         1.8
## 118          7.7         3.8          6.7         2.2
## 119          7.7         2.6          6.9         2.3
## 120          6.0         2.2          5.0         1.5
## 121          6.9         3.2          5.7         2.3
## 122          5.6         2.8          4.9         2.0
## 123          7.7         2.8          6.7         2.0
## 124          6.3         2.7          4.9         1.8
## 125          6.7         3.3          5.7         2.1
## 126          7.2         3.2          6.0         1.8
## 127          6.2         2.8          4.8         1.8
## 128          6.1         3.0          4.9         1.8
## 129          6.4         2.8          5.6         2.1
## 130          7.2         3.0          5.8         1.6
## 131          7.4         2.8          6.1         1.9
## 132          7.9         3.8          6.4         2.0
## 133          6.4         2.8          5.6         2.2
## 134          6.3         2.8          5.1         1.5
## 135          6.1         2.6          5.6         1.4
## 136          7.7         3.0          6.1         2.3
## 137          6.3         3.4          5.6         2.4
## 138          6.4         3.1          5.5         1.8
## 139          6.0         3.0          4.8         1.8
## 140          6.9         3.1          5.4         2.1
## 141          6.7         3.1          5.6         2.4
## 142          6.9         3.1          5.1         2.3
## 143          5.8         2.7          5.1         1.9
## 144          6.8         3.2          5.9         2.3
## 145          6.7         3.3          5.7         2.5
## 146          6.7         3.0          5.2         2.3
## 147          6.3         2.5          5.0         1.9
## 148          6.5         3.0          5.2         2.0
## 149          6.2         3.4          5.4         2.3
## 150          5.9         3.0          5.1         1.8

Plot the data by the classes of iris species

pairs(x, col=iris[,5])

FUZZY C-MEANS CLUSTERING


Fuzzy C-Means (FCM) is a soft custering algorithm proposed by Bezdek (1974; 1981). Unlike K-means algorithm in which each data object is the member of only one cluster, a data object is the member of all clusters with varying degrees of fuzzy memberhip between 0 and 1 in FCM. Hence, the data objects closer to the centers of clusters have higher degrees of membership than objects scattered in the borders of clusters.

Run FCM with Single Start

Initialization

In order to start FCM as well as the other alternating optimization algorithms, an initialization step is required to build the initial cluster prototypes matrix and fuzzy membership degrees matrix. Although this task is usually performed in the initialization step of the clustering algorithm, the initial prototypes and memberships can also be directly input by the user.

FCM is usually started by using an integer specifying the number of clusters. In this case, the prototypes matrix is internally generated by using any of the prototype initalization algorithms which are included in the package ‘inaparc’. The default initialization technique is K-means++ with the current version of fcm function in this package. In the following code block, FCM runs for three clusters with the default values of the remaining arguments.

res.fcm <- fcm(x, centers=3)

Although it is a usual way to run FCM with a pre-determined number of clusters, sometimes the users may wish to use a certain cluster prototypes matrix to start the algorithm. In this case, FCM uses the user-specified prototype matrix instead of internally generated ones as follows:

v0 <- matrix(nrow=3, ncol=4,
     c(5.0, 3.4, 1.4, 0.3,
       6.7, 3.0, 5.6, 2.1,
       5.8, 2.7, 4.3, 1.4),
       byrow=TRUE)
print(v0)
##      [,1] [,2] [,3] [,4]
## [1,]  5.0  3.4  1.4  0.3
## [2,]  6.7  3.0  5.6  2.1
## [3,]  5.8  2.7  4.3  1.4
res.fcm <- fcm(x, centers=v0)

In the following code block, there is another example for initialization of cluster prototypes for three clusters. v, the cluster prototype matrix is initialized by using the K-means++ initalization algorithm (kmpp) in the R package ‘inaparc’.

v0 <- inaparc::kmpp(x, k=3)$v
print(v0)
##      Sepal.Length Sepal.Width Petal.Length Petal.Width
## Cl.1          6.7         3.3          5.7         2.1
## Cl.2          5.1         3.7          1.5         0.4
## Cl.3          5.5         2.3          4.0         1.3
res.fcm <- fcm(x, centers=v0)

There are many other techniques for initialization of cluster prototype matrices in the R package ‘inaparc’. See the package documentation for other alternatives.

FCM can be alternatively started with a user-specified membership degrees matrix. In this case, the function fcm is called with the argument memberships as follows:

u0 <- inaparc::imembrand(nrow(x), k=3)$u
res.fcm <- fcm(x, centers=3, memberships=u0)

In order to generate the matrices of cluster prototypes and membership degrees, users can choose any of existing initialization algorithms in the R package ‘inaparc’. For this purpose, alginitv and alginitu can be speficied for cluster prototypes and membership degrees, respectively.

res.fcm <- fcm(x, centers=3, alginitv="hartiganwong", alginitu="imembrand")

In general, the squared Euclidean distance metric is used with FCM in order to compute the distances between the cluster centers and the data objects. Users can specify the other distance metrics with the argument dmetric as follows:

res.fcm <- fcm(x, centers=3, dmetric="correlation")

Although the argument m, fuzzy exponent is usually choosen as 2 in most of the applications using FCM, users can increase m to get more fuzzified results as follows:

res.fcm <- fcm(x, centers=3, m=4)

There are other input arguments available with the function fcm to control the run of FCM algoritm. For the details, see fcm in the package manual of ppclust.

Clustering Results

Fuzzy Membership Matrix

The fuzzy membership degrees matrix is the main output of the function fcm.

res.fcm <- fcm(x, centers=3)
as.data.frame(res.fcm$u)
##       Cluster 1    Cluster 2    Cluster 3
## 1   0.996623586 0.0010720343 0.0023043797
## 2   0.975852543 0.0074979471 0.0166495094
## 3   0.979825922 0.0064145785 0.0137594999
## 4   0.967427446 0.0101075228 0.0224650314
## 5   0.994470355 0.0017679352 0.0037617094
## 6   0.934574112 0.0206196544 0.0448062334
## 7   0.979491667 0.0065045178 0.0140038150
## 8   0.999547263 0.0001412048 0.0003115325
## 9   0.930379787 0.0219024180 0.0477177955
## 10  0.982722963 0.0053415614 0.0119354753
## 11  0.968042314 0.0102009404 0.0217567454
## 12  0.992137158 0.0024310579 0.0054317837
## 13  0.970640151 0.0091771718 0.0201826777
## 14  0.922969888 0.0252359838 0.0517941280
## 15  0.889758960 0.0376316556 0.0726093846
## 16  0.841344991 0.0543059147 0.1043490943
## 17  0.946925354 0.0174955672 0.0355790790
## 18  0.996652727 0.0010587888 0.0022884844
## 19  0.904135383 0.0303079325 0.0655566844
## 20  0.979189057 0.0066536393 0.0141573036
## 21  0.968604478 0.0095402581 0.0218552641
## 22  0.984832940 0.0047938580 0.0103732023
## 23  0.958657970 0.0138328404 0.0275091893
## 24  0.979427459 0.0061114430 0.0144610982
## 25  0.966919292 0.0098381257 0.0232425828
## 26  0.973568110 0.0079734119 0.0184584784
## 27  0.994845501 0.0015732466 0.0035812524
## 28  0.993348247 0.0020867312 0.0045650218
## 29  0.993675965 0.0019959744 0.0043280604
## 30  0.979516306 0.0062825258 0.0142011680
## 31  0.978727869 0.0064733979 0.0147987334
## 32  0.974364585 0.0079393901 0.0176960245
## 33  0.938520818 0.0203340541 0.0411451283
## 34  0.904170465 0.0323481722 0.0634813626
## 35  0.985065378 0.0045939611 0.0103406605
## 36  0.984993629 0.0048051874 0.0102011840
## 37  0.964184610 0.0115640394 0.0242513503
## 38  0.990890944 0.0029265624 0.0061824935
## 39  0.939684289 0.0192324562 0.0410832553
## 40  0.998289045 0.0005332393 0.0011777153
## 41  0.994727756 0.0016883315 0.0035839126
## 42  0.850735640 0.0469942942 0.1022700657
## 43  0.952615436 0.0152083532 0.0321762107
## 44  0.979288153 0.0063293707 0.0143824764
## 45  0.945271448 0.0166004939 0.0381280580
## 46  0.972146471 0.0086314256 0.0192221039
## 47  0.976793110 0.0073649037 0.0158419861
## 48  0.974220960 0.0081267194 0.0176523205
## 49  0.977220405 0.0072595251 0.0155200700
## 50  0.997072504 0.0009193050 0.0020081913
## 51  0.044575211 0.5011647761 0.4542600127
## 52  0.029161793 0.2068161473 0.7640220596
## 53  0.031266851 0.5999779441 0.3687552045
## 54  0.049350860 0.0804423902 0.8702067502
## 55  0.024106950 0.2171543236 0.7587387266
## 56  0.005739785 0.0204630428 0.9737971719
## 57  0.029795021 0.2972086555 0.6729963240
## 58  0.285183214 0.1323071921 0.5825095938
## 59  0.031231491 0.2477432815 0.7210252279
## 60  0.074761625 0.0946992632 0.8305391116
## 61  0.218422895 0.1450610486 0.6365160568
## 62  0.009186241 0.0287393263 0.9620744331
## 63  0.055629982 0.1011194867 0.8432505316
## 64  0.012112947 0.0882419797 0.8996450736
## 65  0.091648196 0.0921845965 0.8161672075
## 66  0.041718519 0.2683996762 0.6898818049
## 67  0.014153298 0.0526760880 0.9331706135
## 68  0.025894154 0.0483703771 0.9257354685
## 69  0.027143382 0.1374190383 0.8354375798
## 70  0.051559615 0.0707707462 0.8776696387
## 71  0.027615327 0.2507400169 0.7216446559
## 72  0.019494562 0.0462324229 0.9342730153
## 73  0.023969834 0.2705868377 0.7054433284
## 74  0.013932496 0.0833272688 0.9027402351
## 75  0.022905127 0.1011835108 0.8759113625
## 76  0.033939612 0.2112738188 0.7547865687
## 77  0.033605569 0.4427293803 0.5236650507
## 78  0.021186958 0.6724777412 0.3063353005
## 79  0.004935792 0.0261880072 0.9688762010
## 80  0.128324085 0.1046584749 0.7670174397
## 81  0.077808308 0.0898883941 0.8323032979
## 82  0.103783237 0.1007426774 0.7954740859
## 83  0.030983221 0.0503056708 0.9187111084
## 84  0.023969780 0.3197093744 0.6563208453
## 85  0.026380990 0.0824498231 0.8911691872
## 86  0.032141589 0.1707011266 0.7971572848
## 87  0.033453217 0.4111277792 0.5554190041
## 88  0.026863352 0.1154725587 0.8576640891
## 89  0.024091987 0.0469855355 0.9289224771
## 90  0.038179686 0.0623777655 0.8994425488
## 91  0.019629842 0.0492237626 0.9311463956
## 92  0.011616525 0.0727269045 0.9156565701
## 93  0.022518586 0.0417882759 0.9356931378
## 94  0.268938404 0.1327390376 0.5983225587
## 95  0.012680765 0.0284410354 0.9588781993
## 96  0.016783739 0.0376771605 0.9455391002
## 97  0.009577465 0.0230138420 0.9674086932
## 98  0.011406336 0.0447260608 0.9438676033
## 99  0.355359570 0.1245109185 0.5201295118
## 100 0.012691369 0.0267396046 0.9605690263
## 101 0.019357096 0.8599088665 0.1207340375
## 102 0.029295839 0.3551145742 0.6155895872
## 103 0.006072912 0.9557915825 0.0381355053
## 104 0.012525153 0.8455238035 0.1419510432
## 105 0.004754021 0.9576076582 0.0376383212
## 106 0.035453705 0.8118938120 0.1526524831
## 107 0.072974231 0.1670353033 0.7599904662
## 108 0.021893269 0.8629882055 0.1151185253
## 109 0.013991744 0.8686743423 0.1173339139
## 110 0.024412040 0.8610149827 0.1145729771
## 111 0.016764224 0.7733430930 0.2098926828
## 112 0.015755245 0.7611012307 0.2231435240
## 113 0.001166661 0.9888133984 0.0100199402
## 114 0.034362703 0.3056670642 0.6599702328
## 115 0.038368890 0.5006316741 0.4609994357
## 116 0.014063146 0.8498632572 0.1360735970
## 117 0.007161555 0.9132129428 0.0796255018
## 118 0.050581474 0.7636191257 0.1857994001
## 119 0.049175817 0.7575879302 0.1932362525
## 120 0.032185304 0.2570874897 0.7107272062
## 121 0.003826274 0.9704831780 0.0256905480
## 122 0.033638346 0.2593825974 0.7069790567
## 123 0.041964502 0.7832271313 0.1748083664
## 124 0.022799599 0.3814478974 0.5957525037
## 125 0.002913103 0.9753464366 0.0217404607
## 126 0.012903965 0.9119467896 0.0751492456
## 127 0.020976452 0.2712531839 0.7077703643
## 128 0.023089260 0.3300135872 0.6468971528
## 129 0.008357837 0.9086355158 0.0830066469
## 130 0.014442890 0.8908235463 0.0947335634
## 131 0.019781892 0.8727910324 0.1074270759
## 132 0.050896659 0.7601277386 0.1889756026
## 133 0.008956233 0.9061983726 0.0848453940
## 134 0.023388641 0.4364076302 0.5402037287
## 135 0.031183223 0.5760872990 0.3927294776
## 136 0.028656043 0.8395903521 0.1317536050
## 137 0.017225789 0.8540772196 0.1286969912
## 138 0.009783580 0.8801373939 0.1100790258
## 139 0.021721860 0.2283825037 0.7498956358
## 140 0.003489143 0.9675488010 0.0289620560
## 141 0.005076701 0.9572481918 0.0376751069
## 142 0.015401036 0.8551179505 0.1294810131
## 143 0.029295839 0.3551145742 0.6155895872
## 144 0.005247653 0.9610294118 0.0337229350
## 145 0.009699732 0.9271271417 0.0631731267
## 146 0.011262231 0.8823507060 0.1063870633
## 147 0.025795931 0.4666788274 0.5075252416
## 148 0.012113671 0.8314467113 0.1564396177
## 149 0.021581260 0.7893823004 0.1890364396
## 150 0.026918882 0.3913000198 0.5817810983

Initial and Final Cluster Prototypes

Initial and final cluster prototypes matrices can be achieved as follows:

res.fcm$v0
##           Sepal.Length Sepal.Width Petal.Length Petal.Width
## Cluster 1          4.6         3.1          1.5         0.2
## Cluster 2          6.5         3.0          5.2         2.0
## Cluster 3          6.1         2.8          4.0         1.3
res.fcm$v
##           Sepal.Length Sepal.Width Petal.Length Petal.Width
## Cluster 1     5.003966    3.414089     1.482816   0.2535463
## Cluster 2     6.775011    3.052382     5.646782   2.0535467
## Cluster 3     5.888932    2.761069     4.363952   1.3973150

Summary of Clustering Results

The function fcm returns the clustering results as an intance of ‘ppclust’ class. This object is summarized with the summary method of the package ‘ppclust’ as follows:

summary(res.fcm)
## Summary for 'res.fcm'
## 
## Number of data objects:  150 
## 
## Number of clusters:  3 
## 
## Crisp clustering vector:
##   [1] 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1
##  [38] 1 1 1 1 1 1 1 1 1 1 1 1 1 2 3 2 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3
##  [75] 3 3 3 2 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 2 3 2 2 2 2 3 2 2 2 2
## [112] 2 2 3 2 2 2 2 2 3 2 3 2 3 2 2 3 3 2 2 2 2 2 3 2 2 2 2 3 2 2 2 3 2 2 2 3 2
## [149] 2 3
## 
## Initial cluster prototypes:
##           Sepal.Length Sepal.Width Petal.Length Petal.Width
## Cluster 1          4.6         3.1          1.5         0.2
## Cluster 2          6.5         3.0          5.2         2.0
## Cluster 3          6.1         2.8          4.0         1.3
## 
## Final cluster prototypes:
##           Sepal.Length Sepal.Width Petal.Length Petal.Width
## Cluster 1     5.003966    3.414089     1.482816   0.2535463
## Cluster 2     6.775011    3.052382     5.646782   2.0535467
## Cluster 3     5.888932    2.761069     4.363952   1.3973150
## 
## Distance between the final cluster prototypes
##           Cluster 1 Cluster 2
## Cluster 2 23.846049          
## Cluster 3 10.818752  2.946292
## 
## Difference between the initial and final cluster prototypes
##           Sepal.Length Sepal.Width Petal.Length Petal.Width
## Cluster 1    0.4039660  0.31408886  -0.01718447  0.05354632
## Cluster 2    0.2750112  0.05238227   0.44678178  0.05354666
## Cluster 3   -0.2110676 -0.03893064   0.36395164  0.09731504
## 
## Root Mean Squared Deviations (RMSD): 0.4945891 
## Mean Absolute Deviation (MAD): 3.103697 
## 
## Membership degrees matrix (top and bottom 5 rows): 
##   Cluster 1   Cluster 2   Cluster 3
## 1 0.9966236 0.001072034 0.002304380
## 2 0.9758525 0.007497947 0.016649509
## 3 0.9798259 0.006414579 0.013759500
## 4 0.9674274 0.010107523 0.022465031
## 5 0.9944704 0.001767935 0.003761709
## ...
##      Cluster 1 Cluster 2 Cluster 3
## 146 0.01126223 0.8823507 0.1063871
## 147 0.02579593 0.4666788 0.5075252
## 148 0.01211367 0.8314467 0.1564396
## 149 0.02158126 0.7893823 0.1890364
## 150 0.02691888 0.3913000 0.5817811
## 
## Descriptive statistics for the membership degrees by clusters
##           Size       Min        Q1      Mean    Median        Q3       Max
## Cluster 1   50 0.8413450 0.9541261 0.9645018 0.9763228 0.9850474 0.9995473
## Cluster 2   40 0.5006317 0.7807561 0.8351480 0.8604619 0.9122633 0.9888134
## Cluster 3   60 0.5075252 0.6697398 0.7826035 0.7963157 0.9164202 0.9737972
## 
## Dunn's Fuzziness Coefficients:
## dunn_coeff normalized 
##  0.7833975  0.6750962 
## 
## Within cluster sum of squares by cluster:
##        1        2        3 
## 15.15100 27.05750 36.81767 
## (between_SS / total_SS =  88.04%) 
## 
## Available components: 
##  [1] "u"          "v"          "v0"         "d"          "x"         
##  [6] "cluster"    "csize"      "sumsqrs"    "k"          "m"         
## [11] "iter"       "best.start" "func.val"   "comp.time"  "inpargs"   
## [16] "algorithm"  "call"

All available components of the ‘ppclust’ object are listed at the end of summary. These elements can be accessed using as the attributes of the object. For example, the execution time of the run of FCM is accessed as follows:

res.fcm$comp.time
## [1] 0.297

Run FCM with Multiple Starts

In order to find an optimal solution, the function fcm can be started for multiple times. As seen in the following code chunk, the argument nstart is used for this purpose.

res.fcm <- fcm(x, centers=3, nstart=5)

When the multiple start is performed, either initial cluster prototypes or initial membership degrees could be wanted to keep unchanged between the starts of algorithm. In this case, the arguments fixcent and fixmemb are used for fixing the initial cluster prototypes matrix and initial membership degrees matrix, respectively.

res.fcm <- fcm(x, centers=3, nstart=5, fixmemb=TRUE)

Both the prototypes and memberships cannot be fixed at the same time.

Display the best solution

The clustering result contains some outputs providing information about some components such as the objective function values, number of iterations and computing time obtained with each start of the algorithm. The following code chunk demonstrates these outputs.

res.fcm$func.val
## [1] 60.50571 60.50571 60.50571 60.50571 60.50571
res.fcm$iter
## [1] 48 43 47 45 50
res.fcm$comp.time
## [1] 0.295 0.274 0.291 0.286 0.315

Among the outputs from succesive starts of the algorithm, the best solution is obtained from the start giving the minimum value of the objective function, and stored as the the final clustering result of the multiple starts of FCM.

res.fcm$best.start
## [1] 1

Display the summary of clustering results

As described for the single start of FCM above, the result of multiple starts of FCM is displayed by using summary method of the ‘ppclust’ package.

summary(res.fcm)
## Summary for 'res.fcm'
## 
## Number of data objects:  150 
## 
## Number of clusters:  3 
## 
## Crisp clustering vector:
##   [1] 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1
##  [38] 1 1 1 1 1 1 1 1 1 1 1 1 1 2 3 2 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3
##  [75] 3 3 3 2 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 2 3 2 2 2 2 3 2 2 2 2
## [112] 2 2 3 2 2 2 2 2 3 2 3 2 3 2 2 3 3 2 2 2 2 2 3 2 2 2 2 3 2 2 2 3 2 2 2 3 2
## [149] 2 3
## 
## Initial cluster prototypes:
##           Sepal.Length Sepal.Width Petal.Length Petal.Width
## Cluster 1          6.5         3.0          5.2         2.0
## Cluster 2          5.4         3.7          1.5         0.2
## Cluster 3          5.0         2.0          3.5         1.0
## 
## Final cluster prototypes:
##           Sepal.Length Sepal.Width Petal.Length Petal.Width
## Cluster 1     5.003966    3.414089     1.482816   0.2535463
## Cluster 2     6.775011    3.052382     5.646782   2.0535467
## Cluster 3     5.888932    2.761069     4.363952   1.3973150
## 
## Distance between the final cluster prototypes
##           Cluster 1 Cluster 2
## Cluster 2 23.846049          
## Cluster 3 10.818752  2.946292
## 
## Difference between the initial and final cluster prototypes
##           Sepal.Length Sepal.Width Petal.Length Petal.Width
## Cluster 1   -1.4960340   0.4140889   -3.7171845   -1.746454
## Cluster 2    1.3750112  -0.6476177    4.1467818    1.853547
## Cluster 3    0.8889324   0.7610694    0.8639516    0.397315
## 
## Root Mean Squared Deviations (RMSD): 3.851075 
## Mean Absolute Deviation (MAD): 24.41065 
## 
## Membership degrees matrix (top and bottom 5 rows): 
##   Cluster 1   Cluster 2   Cluster 3
## 1 0.9966236 0.001072034 0.002304380
## 2 0.9758525 0.007497947 0.016649509
## 3 0.9798259 0.006414579 0.013759500
## 4 0.9674274 0.010107523 0.022465031
## 5 0.9944704 0.001767935 0.003761709
## ...
##      Cluster 1 Cluster 2 Cluster 3
## 146 0.01126223 0.8823507 0.1063871
## 147 0.02579593 0.4666788 0.5075252
## 148 0.01211367 0.8314467 0.1564396
## 149 0.02158126 0.7893823 0.1890364
## 150 0.02691888 0.3913000 0.5817811
## 
## Descriptive statistics for the membership degrees by clusters
##           Size       Min        Q1      Mean    Median        Q3       Max
## Cluster 1   50 0.8413450 0.9541261 0.9645018 0.9763228 0.9850474 0.9995473
## Cluster 2   40 0.5006317 0.7807561 0.8351480 0.8604619 0.9122633 0.9888134
## Cluster 3   60 0.5075252 0.6697398 0.7826035 0.7963157 0.9164202 0.9737972
## 
## Dunn's Fuzziness Coefficients:
## dunn_coeff normalized 
##  0.7833975  0.6750962 
## 
## Within cluster sum of squares by cluster:
##        1        2        3 
## 15.15100 27.05750 36.81767 
## (between_SS / total_SS =  88.04%) 
## 
## Available components: 
##  [1] "u"          "v"          "v0"         "d"          "x"         
##  [6] "cluster"    "csize"      "sumsqrs"    "k"          "m"         
## [11] "iter"       "best.start" "func.val"   "comp.time"  "inpargs"   
## [16] "algorithm"  "call"

VISUALIZATION OF THE CLUSTERING RESULTS


Pairwise Scatter Plots

There are many ways of visual representation of the clustering results. One common techique is to display the clustering results by using pairs of the features. The ‘plotcluster’ can be used to plot the clustering results as follows:

plotcluster(res.fcm, cp=1, trans=TRUE)

In the plot above, clustering result is shown with pairwise scatter plots by using color palette 1 and transparent colors. The details can be viewed on the package manual for the function ‘plotcluster’.

Cluster Plot with fviz_cluster

There are some nice versions of the cluster plots which are available in some of the R packages. One of them is the function fviz_cluster of the package ‘factoextra’ (Kassambara & Mundt, 2017). In order to use this function for the fuzzy clustering result, first the fuzzy clustering object of ppclust should be converted to kmeans object by using the ppclust2 of the package ‘ppclust’ as shown in the first line of the code chunk as follows:

res.fcm2 <- ppclust2(res.fcm, "kmeans")
factoextra::fviz_cluster(res.fcm2, data = x, 
  ellipse.type = "convex",
  palette = "jco",
  repel = TRUE)

Cluster Plot with clusplot

User can also use the function clusplot in the package ‘cluster’ (Maechler et al, 2017) for plotting the clustering results. For this purpose, the fuzzy clustering object of ppclust should be converted to fanny object by using the ppclust2 function of the package ‘ppclust’ as seen in the following code chunk.

res.fcm3 <- ppclust2(res.fcm, "fanny")

cluster::clusplot(scale(x), res.fcm3$cluster,  
  main = "Cluster plot of Iris data set",
  color=TRUE, labels = 2, lines = 2, cex=1)

VALIDATION OF THE CLUSTERING RESULTS


Cluster validation is an evaluation process for the goodness of the clustering result. For this purpose, various validity indexes have been proposed in the related literature. Since clustering is an unsupervised learning analysis which does not use any external information, the internal indexes are used to validate the clustering results. Although there are many internal indexes have originally been proposed for working with hard membership degrees produced by the K-means and its variants, most of these indexes cannot be used for fuzzy clustering results. In R environment, Partition Entropy (PE), Partition Coefficient (PC) and Modified Partition Coefficient (MPC) and Fuzzy Silhouette Index are available in ‘fclust’ package (Ferraro & Giordani, 2015), and can be used as follows:

res.fcm4 <- ppclust2(res.fcm, "fclust")
idxsf <- SIL.F(res.fcm4$Xca, res.fcm4$U, alpha=1)
idxpe <- PE(res.fcm4$U)
idxpc <- PC(res.fcm4$U)
idxmpc <- MPC(res.fcm4$U)
cat("Partition Entropy: ", idxpe)
## Partition Entropy:  0.3954916
cat("Partition Coefficient: ", idxpc)
## Partition Coefficient:  0.7833975
cat("Modified Partition Coefficient: ", idxmpc)
## Modified Partition Coefficient:  0.6750962
cat("Fuzzy Silhouette Index: ", idxsf)
## Fuzzy Silhouette Index:  0.8091446

References


Anderson, E. (1935). The irises of the GASPE peninsula, in Bull. Amer. Iris Soc., 59: 2-5.

Bezdek, J.C. (1974). Cluster validity with fuzzy sets. J. Cybern., 3: 58-73.

Bezdek J.C. (1981). . Plenum, NY. https://isbnsearch.org/isbn/0306406713

Ferraro, M.B. & Giordani, P. (2015). A toolbox for fuzzy clustering using the R programming language. Fuzzy Sets and Systems, 279, 1-16. http://dx.doi.org/10.1016/j.fss.2015.05.001

Kassambara, A. & Mundt, F. (2017). factoextra: Extract and Visualize the Results of Multivariate Data Analyses. R package version 1.0.5. https://CRAN.R-project.org/package=factoextra

Maechler, M., Rousseeuw, P., Struyf, A., Hubert, M. & Hornik, K.(2017). cluster: Cluster Analysis Basics and Extensions. R package version 2.0.6. https://CRAN.R-project.org/package=cluster