validation_kproto {clustMixType} | R Documentation |
Validating k Prototypes Clustering
Description
Calculating the preferred validation index for a k-Prototypes clustering with k clusters or computing the optimal number of clusters based on the choosen index for k-Prototype clustering. Possible validation indices are: cindex
, dunn
, gamma
, gplus
, mcclain
, ptbiserial
, silhouette
and tau
.
Usage
validation_kproto(
method = "silhouette",
object = NULL,
data = NULL,
type = "huang",
k = NULL,
lambda = NULL,
kp_obj = "optimal",
verbose = FALSE,
...
)
Arguments
method |
Character specifying the validation index: |
object |
Object of class |
data |
Original data; only required if |
type |
Character, to specify the distance for clustering; either |
k |
Vector specifying the search range for optimum number of clusters; if |
lambda |
Factor to trade off between Euclidean distance of numeric variables and simple matching coefficient between categorical variables. |
kp_obj |
character either "optimal" or "all": Output of the index-optimal clustering (kp_obj == "optimal") or all computed cluster partitions (kp_obj == "all"); only required if |
verbose |
Logical, whether additional information about process should be printed. |
... |
Further arguments passed to
|
Details
More information about the implemented validation indices:
-
cindex
Forand
it is necessary to calculate the distances between all pairs of points in the entire data set (
).
is the sum of the "total number of pairs of objects belonging to the same cluster" smallest distances and
is the sum of the "total number of pairs of objects belonging to the same cluster" largest distances.
is the sum of the within-cluster distances.
The minimum value of the index is used to indicate the optimal number of clusters. -
dunn
The following applies: The dissimilarity between the two clustersand
is defined as
and the diameter of a cluster is defined as
.
The maximum value of the index is used to indicate the optimal number of clusters. -
gamma
Comparisons are made between all within-cluster dissimilarities and all between-cluster dissimilarities.is the number of concordant comparisons and
is the number of discordant comparisons. A comparison is named concordant (resp. discordant) if a within-cluster dissimilarity is strictly less (resp. strictly greater) than a between-cluster dissimilarity.
The maximum value of the index is used to indicate the optimal number of clusters. -
gplus
Comparisons are made between all within-cluster dissimilarities and all between-cluster dissimilarities.is the number of discordant comparisons and a comparison is named discordant if a within-cluster dissimilarity is strictly greater than a between-cluster dissimilarity.
The minimum value of the index is used to indicate the optimal number of clusters. -
mcclain
is the sum of within-cluster distances divided by the number of within-cluster distances and
is the sum of between-cluster distances divided by the number of between-cluster distances.
The minimum value of the index is used to indicate the optimal number of clusters. ptbiserial
is the sum of within-cluster distances divided by the number of within-cluster distances and
is the sum of between-cluster distances divided by the number of between-cluster distances.
is the total number of pairs of objects in the data,
is the total number of pairs of objects belonging to the same cluster and
is the total number of pairs of objects belonging to different clusters.
is the standard deviation of all distances.
The maximum value of the index is used to indicate the optimal number of clusters.-
silhouette
is the average dissimilarity of the ith object to all other objects of the same/own cluster.
, where
is the average dissimilarity of the ith object to all the other clusters except the own/same cluster.
The maximum value of the index is used to indicate the optimal number of clusters. -
tau
Comparisons are made between all within-cluster dissimilarities and all between-cluster dissimilarities.is the number of concordant comparisons and
is the number of discordant comparisons. A comparison is named concordant (resp. discordant) if a within-cluster dissimilarity is strictly less (resp. strictly greater) than a between-cluster dissimilarity.
is the total number of distances
and
is the number of comparisons of two pairs of objects where both pairs represent within-cluster comparisons or both pairs are between-cluster comparisons.
The maximum value of the index is used to indicate the optimal number of clusters.
Value
For computing the optimal number of clusters based on the choosen validation index for k-Prototype clustering the output contains:
k_opt |
optimal number of clusters (sampled in case of ambiguity) |
index_opt |
index value of the index optimal clustering |
indices |
calculated indices for |
kp_obj |
if(kp_obj == "optimal") the kproto object of the index optimal clustering and if(kp_obj == "all") all kproto which were calculated |
For computing the index-value for a given k-Prototype clustering the output contains:
index |
calculated index-value |
Author(s)
Rabea Aschenbruck
References
Aschenbruck, R., Szepannek, G. (2020): Cluster Validation for Mixed-Type Data. Archives of Data Science, Series A, Vol 6, Issue 1. doi:10.5445/KSP/1000098011/02.
Charrad, M., Ghazzali, N., Boiteau, V., Niknafs, A. (2014): NbClust: An R Package for Determining the Relevant Number of Clusters in a Data Set. Journal of Statistical Software, Vol 61, Issue 6. doi:10.18637/jss.v061.i06.
Examples
## Not run:
# generate toy data with factors and numerics
n <- 10
prb <- 0.99
muk <- 2.5
x1 <- sample(c("A","B"), 2*n, replace = TRUE, prob = c(prb, 1-prb))
x1 <- c(x1, sample(c("A","B"), 2*n, replace = TRUE, prob = c(1-prb, prb)))
x1 <- as.factor(x1)
x2 <- sample(c("A","B"), 2*n, replace = TRUE, prob = c(prb, 1-prb))
x2 <- c(x2, sample(c("A","B"), 2*n, replace = TRUE, prob = c(1-prb, prb)))
x2 <- as.factor(x2)
x3 <- c(rnorm(n, mean = -muk), rnorm(n, mean = muk), rnorm(n, mean = -muk), rnorm(n, mean = muk))
x4 <- c(rnorm(n, mean = -muk), rnorm(n, mean = muk), rnorm(n, mean = -muk), rnorm(n, mean = muk))
x <- data.frame(x1,x2,x3,x4)
# calculate optimal number of cluster, index values and clusterpartition with Silhouette-index
val <- validation_kproto(method = "silhouette", data = x, k = 3:5, nstart = 5)
# apply k-prototypes
kpres <- kproto(x, 4, keep.data = TRUE)
# calculate cindex-value for the given clusterpartition
cindex_value <- validation_kproto(method = "cindex", object = kpres)
## End(Not run)