clustMixType (version 0.2-2)

dunn_kproto: Validating k Prototypes Clustering: Dunn index

Description

Calculating the Dunn index for a k-Prototypes clustering with k clusters or computing the optimal number of clusters based on the Dunn index for k-Prototype clustering.

Usage

dunn_kproto(object = NULL, data = NULL, k = NULL, ...)

Arguments

object

Object of class kproto resulting from a call with kproto(..., keep.data=TRUE)

data

Original data; only required if object == NULL.

k

Vector specifying the search range for optimum number of clusters; if NULL the range will set as 2:sqrt(n). Only required if object == NULL.

...

Further arguments passed to kproto, like:

  • nstart: If > 1 repetetive computations of kproto with random initializations are computed.

  • lambda: Factor to trade off between Euclidean distance of numeric variables and simple matching coefficient between categorical variables.

  • verbose: Logical whether information about the cluster procedure should be given. Caution: If verbose=FALSE, the reduction of the number of clusters is not mentioned.

Value

For computing the optimal number of clusters based on the Dunn index for k-Prototype clustering the output contains:

k_opt

optimal number of clusters

indices

calculated indices for \(k=2,...,k_{max}\)

For computing the Dunn index-value for a given k-Prototype clustering the output contains:

index

calculated index-value

Details

$$Dunn = \frac{\min_{1 \leq i < j \leq q} d(C_i, C_j)}{\max_{1 \leq k \leq q} diam(C_k)}$$ The following applies: The dissimilarity between the two clusters \(C_i\) and \(C_j\) is defined as \(d(C_i, C_j)=\min_{x \in C_i, y \in C_j} d(x,y)\) and the diameter of a cluster is defined as \(diam(C_k)=\max_{x,y \in C} d(x,y)\). The maximum value of the index is used to indicate the optimal number of clusters.

References

See Also

Other clustervalidation indices: dunn_kproto, gamma_kproto, gplus_kproto, mcclain_kproto, ptbiserial_kproto, silhouette_kproto, tau_kproto

Examples

Run this code
# 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)

# apply k prototyps
kpres <- kproto(x, 4, keep.data=TRUE)

# calculate index-value
dunn_value <- dunn_kproto(object = kpres)

# }
# NOT RUN {
# calculate optimal number of cluster
k_opt <- dunn_kproto(data = x, k = 3:5, nstart = 5, verbose = FALSE)
# }
# NOT RUN {

# }

Run the code above in your browser using DataLab