Fuzzy C-Shell Clustering
cshell.RdThe c-shell clustering algorithm, the shell prototype-based version (ring prototypes) of the fuzzy kmeans clustering method.
Usage
cshell(x, centers, iter.max=100, verbose=FALSE, dist="euclidean",
method="cshell", m=2, radius = NULL)Arguments
- x
The data matrix, were columns correspond to the variables and rows to observations.
- centers
Number of clusters or initial values for cluster centers
- iter.max
Maximum number of iterations
- verbose
If
TRUE, make some output during learning- dist
Must be one of the following: If
"euclidean", the mean square error, if"manhattan", the mean absolute error is computed. Abbreviations are also accepted.- method
Currently, only the
"cshell"method; the c-shell fuzzy clustering method- m
The degree of fuzzification. It is defined for values greater than 1
- radius
The radius of resulting clusters
Details
The data given by x is clustered by the fuzzy c-shell algorithm.
If centers is a matrix, its rows are taken as the initial cluster
centers. If centers is an integer, centers rows
of x are randomly chosen as initial values.
The algorithm stops when the maximum number of iterations (given by
iter.max) is reached.
If verbose is TRUE, it displays for each iteration the number
the value of the objective function.
If dist is "euclidean", the distance between the
cluster center and the data points is the Euclidean distance (ordinary
kmeans algorithm). If "manhattan", the distance between the
cluster center and the data points is the sum of the absolute values
of the distances of the coordinates.
If method is "cshell", then we have the c-shell
fuzzy clustering method.
The parameters m defines the degree of fuzzification. It is
defined for real values greater than 1 and the bigger it is the more
fuzzy the membership values of the clustered data points are.
The parameter radius is by default set to 0.2 for every
cluster.
Value
cshell returns an object of class "cshell".
- centers
The final cluster centers.
- size
The number of data points in each cluster.
- cluster
Vector containing the indices of the clusters where the data points are assigned to. The maximum membership value of a point is considered for partitioning it to a cluster.
- iter
The number of iterations performed.
- membership
a matrix with the membership values of the data points to the clusters.
- withinerror
Returns the sum of square distances within the clusters.
- call
Returns a call in which all of the arguments are specified by their names.
References
Rajesh N. Dave. Fuzzy Shell-Clustering and Applications to Circle Detection in Digital Images. Int. J. of General Systems, Vol. 16, pp. 343-355, 1996.
Examples
## a 2-dimensional example
x <- rbind(matrix(rnorm(50, sd = 0.3), ncol = 2),
matrix(rnorm(50, mean = 1, sd=0.3), ncol = 2))
cl <- cshell(x, 2, 20, verbose = TRUE, method = "cshell", m = 2)
#> Iteration: 1 Error: 0.0317656192
#> Iteration: 2 Epsi2: 18.0300922366
#> Iteration: 2 Error: 0.0284355344
#> Iteration: 3 Epsi2: 14.5909299138
#> Iteration: 3 Error: 0.0246995601
#> Iteration: 4 Epsi2: 8.7592561949
#> Iteration: 4 Error: 0.0223561159
#> Iteration: 5 Epsi2: 6.2345946961
#> Iteration: 5 Error: 0.0194313739
#> Iteration: 6 Epsi2: 2.7899574363
#> Iteration: 6 Error: 0.0181781516
#> Iteration: 7 Epsi2: 1.4094098460
#> Iteration: 7 Error: 0.0178983110
#> Iteration: 8 Epsi2: 0.8611228287
#> Iteration: 8 Error: 0.0178152877
#> Iteration: 9 Epsi2: 0.5602410942
#> Iteration: 9 Error: 0.0177740024
#> Iteration: 10 Epsi2: 0.2662051168
#> Iteration: 10 Error: 0.0177588922
#> Iteration: 11 converged, Error: 0.1642056212
#> Iteration: 11 Error: 0.0177476041
print(cl)
#> Fuzzy c-means clustering with 2 clusters
#>
#> Cluster centers:
#> [,1] [,2]
#> 1 0.3369830 0.2915182
#> 2 0.7677189 0.5842502
#>
#> Memberships:
#> 1 2
#> [1,] 0.0016701803 0.9983298197
#> [2,] 0.0222895667 0.9777104333
#> [3,] 0.3166518915 0.6833481085
#> [4,] 0.0014978196 0.9985021804
#> [5,] 0.0457113907 0.9542886093
#> [6,] 0.0047635492 0.9952364508
#> [7,] 0.0015842603 0.9984157397
#> [8,] 0.9410556387 0.0589443613
#> [9,] 0.0352848813 0.9647151187
#> [10,] 0.2017209903 0.7982790097
#> [11,] 0.0083336245 0.9916663755
#> [12,] 0.9221261901 0.0778738099
#> [13,] 0.1007964286 0.8992035714
#> [14,] 0.2443427985 0.7556572015
#> [15,] 0.9803239258 0.0196760742
#> [16,] 0.9909381427 0.0090618573
#> [17,] 0.9487001405 0.0512998595
#> [18,] 0.4289579508 0.5710420492
#> [19,] 0.4959662024 0.5040337976
#> [20,] 0.1408096741 0.8591903259
#> [21,] 0.0834521110 0.9165478890
#> [22,] 0.0615471157 0.9384528843
#> [23,] 0.0017123893 0.9982876107
#> [24,] 0.9562406912 0.0437593088
#> [25,] 0.0142216528 0.9857783472
#> [26,] 0.5524127294 0.4475872706
#> [27,] 0.0480705399 0.9519294601
#> [28,] 0.0242270284 0.9757729716
#> [29,] 0.9570376167 0.0429623833
#> [30,] 0.9209252221 0.0790747779
#> [31,] 0.9610408777 0.0389591223
#> [32,] 0.9734715747 0.0265284253
#> [33,] 0.3714824375 0.6285175625
#> [34,] 0.0001690426 0.9998309574
#> [35,] 0.0524782103 0.9475217897
#> [36,] 0.9708420973 0.0291579027
#> [37,] 0.9995023861 0.0004976139
#> [38,] 0.0311154433 0.9688845567
#> [39,] 0.8121020057 0.1878979943
#> [40,] 0.8834971596 0.1165028404
#> [41,] 0.9968247213 0.0031752787
#> [42,] 0.9920258288 0.0079741712
#> [43,] 0.9822035817 0.0177964183
#> [44,] 0.0923990411 0.9076009589
#> [45,] 0.4607847491 0.5392152509
#> [46,] 0.2480535209 0.7519464791
#> [47,] 0.0604587600 0.9395412400
#> [48,] 0.9896420904 0.0103579096
#> [49,] 0.7395691023 0.2604308977
#> [50,] 0.6735220365 0.3264779635
#>
#> Closest hard clustering:
#> [1] 2 2 2 2 2 2 2 1 2 2 2 1 2 2 1 1 1 2 2 2 2 2 2 1 2 1 2 2 1 1 1 1 2 2 2 1 1 2
#> [39] 1 1 1 1 1 2 2 2 2 1 1 1
#>
#> Available components:
#> [1] "centers" "radius" "size" "cluster" "iter"
#> [6] "membership" "withinerror" "call"