Defuzzifies a fuzzy partition
defuzzify.Rd
Transforms a fuzzy classification into a crisp (hard) classification.
Arguments
- object
A site-by-group fuzzy membership matrix. Alternatively, an object of class 'vegclust' or 'vegclass'.
- method
Either
"max"
to choose for the maximum membership value across clusters, or"cut"
for an alpha-cut.- alpha
Threshold for the alpha-cut, bounded between 0 and 1.
- na.rm
If
TRUE
removes the objects that do not belong to any cluster when usingmethod="cut"
.
Details
Alpha-cut means that memberships lower than alpha are transformed into 0 while memberships higher than alpha are transformed into 1. This means that if alpha values are low (i.e. close to 0), an object may belong to more than one group after defuzzification. These will generate a concatenation of cluster names in the output cluster
vector and a row with sum more than one in the memb
matrix). Similarly, if alpha is high (i.e. close to 1) there are objects that may be left unclassified. These will get NA
in the cluster
vector and zero row in the memb
matrix.
Value
A list with the following items:
- memb
A data frame with the hard membership partition.
- cluster
A vector (factor) with the name of the cluster for each object.
References
Davé, R. N. and R. Krishnapuram (1997) Robust clustering methods: a unified view. IEEE Transactions on Fuzzy Systems 5, 270-293.
Examples
## Loads data
data(wetland)
## This equals the chord transformation
## (see also \code{\link{decostand}} in package vegan)
wetland.chord = as.data.frame(sweep(as.matrix(wetland), 1,
sqrt(rowSums(as.matrix(wetland)^2)), "/"))
## Create noise clustering with 3 clusters. Perform 10 starts from random seeds
## and keep the best solution
wetland.nc = vegclust(wetland.chord, mobileCenters=3, m = 1.2, dnoise=0.75,
method="NC", nstart=10)
## Defuzzification using an alpha-cut (alpha=0.5)
wetland.nc.df = defuzzify(wetland.nc$memb, method="cut")
## Cluster vector, with 'N' for objects that are unclassified,
## and 'NA' for objects that are intermediate
print(wetland.nc.df$cluster)
#> 5 8 13 4 17 3 9 21 16 14 2 15 1 7 10 40
#> "M1" "M1" "M1" "M1" "M1" "N" "N" "M1" "M1" "M1" "M1" "M1" "M1" "N" "N" "M3"
#> 23 25 22 20 6 18 12 39 19 11 30 34 28 31 26 29
#> "M3" "M3" NA "M3" "M3" "M3" "M3" "M3" "M3" "M3" "N" "M2" "N" "M2" "N" "N"
#> 33 24 36 37 41 27 32 35 38
#> "M3" "M2" "M2" "M2" "M2" "N" "N" "N" "M1"
## Hard membership matrix (site 22 does not get any cluster assigned)
print(wetland.nc.df$memb)
#> M1 M2 M3 N
#> 5 1 0 0 0
#> 8 1 0 0 0
#> 13 1 0 0 0
#> 4 1 0 0 0
#> 17 1 0 0 0
#> 3 0 0 0 1
#> 9 0 0 0 1
#> 21 1 0 0 0
#> 16 1 0 0 0
#> 14 1 0 0 0
#> 2 1 0 0 0
#> 15 1 0 0 0
#> 1 1 0 0 0
#> 7 0 0 0 1
#> 10 0 0 0 1
#> 40 0 0 1 0
#> 23 0 0 1 0
#> 25 0 0 1 0
#> 22 0 0 0 0
#> 20 0 0 1 0
#> 6 0 0 1 0
#> 18 0 0 1 0
#> 12 0 0 1 0
#> 39 0 0 1 0
#> 19 0 0 1 0
#> 11 0 0 1 0
#> 30 0 0 0 1
#> 34 0 1 0 0
#> 28 0 0 0 1
#> 31 0 1 0 0
#> 26 0 0 0 1
#> 29 0 0 0 1
#> 33 0 0 1 0
#> 24 0 1 0 0
#> 36 0 1 0 0
#> 37 0 1 0 0
#> 41 0 1 0 0
#> 27 0 0 0 1
#> 32 0 0 0 1
#> 35 0 0 0 1
#> 38 1 0 0 0