BayesCVIs {BayesCVI}R Documentation

Bayesian cluster validity index

Description

Compute Bayesian cluster validity index (BCVI) from two to kmax groups using an underlying cluster validity index (CVI) and Dirichlet prior parameters of the user's choice. The full detail of BCVI can be found in the paper Wiroonsri and Preedasawakul (2024).

Usage

BayesCVIs(CVI, n, kmax, opt.pt, alpha = "default", mult.alpha = 1/2)

Arguments

CVI

the CVI values for k from 2 to kmax to be used as the underlying index for computing BCVI.

n

a number of data point.

kmax

a maximum number of clusters to be considered.

opt.pt

a character string indicating whether the maximum or the minimum of CVI specifies the optimal number of groups ("min" or "max").

alpha

Dirichlet prior parameters α2,...,αk\alpha_2,...,\alpha_k where αk\alpha_k is the parameter corresponding to "the probability of having k groups" (selecting each αk\alpha_k between 0 to 30 is recommended and using the other parameter mult.alpha to be its multiplier. The default is "default".)

mult.alpha

the power ss from nsn^s to be multiplied to the Dirichlet prior parameters alpha (selecting mult.alpha in [0,1) is recommended). The default is 12\frac{1}{2}.

Details

BCVI is defined as follows. Let

rk(x)=maxjCVI(j)CVI(k)i=2K(maxjCVI(j)CVI(i))r_k(\bf x) = \dfrac{\max_j CVI(j)- CVI(k)}{\sum_{i=2}^K (\max_j CVI(j) - CVI(i))}

for a CVI such that the smallest value indicates the optimal number of clusters and

rk(x)=CVI(k)minjCVI(j)i=2K(CVI(i)minjCVI(j))r_k(\bf x) = \dfrac{CVI(k)-\min_j CVI(j)}{\sum_{i=2}^K (CVI(i)-\min_j CVI(j))}

for a CVI such that the largest value indicates the optimal number of clusters. Assume that

f(xp)=C(p)k=2Kpknrk(x)f({\bf x}|{\bf p}) = C({\bf p}) \prod_{k=2}^Kp_k^{nr_k(x)}

represents the conditional probability density function of the dataset given p\bf p, where C(p)C({\bf p}) is the normalizing constant. Assume further that p{\bf p} follows a Dirichlet prior distribution with parameters α=(α2,,αK){\bm \alpha} = (\alpha_2,\ldots,\alpha_K). The posterior distribution of p\bf p still remains a Dirichlet distribution with parameters (α2+nr2(x),,αK+nrK(x))(\alpha_2+nr_2({\bf x}),\ldots,\alpha_K+nr_K({\bf x})).

The BCVI is then defined as

BCVI(k)=E[pkx]=αk+nrk(x)α0+nBCVI(k) = E[p_k|{\bf x}] = \frac{\alpha_k + nr_k({\bf x})}{\alpha_0+n}

where α0=k=2Kαk.\alpha_0 = \sum_{k=2}^K \alpha_k.

The variance of pkp_k can be computed as

Var(pkx)=(αk+nrk(x))(α0+nαknrk(x))(α0+n)2(α0+n+1).Var(p_k|{\bf x}) = \dfrac{(\alpha_k + nr_k(x))(\alpha_0 + n -\alpha_k-nr_k(x))}{(\alpha_0 + n)^2(\alpha_0 + n +1 )}.

Value

BCVI

the dataframe where the first and the second columns are the number of groups k and BCVI(k)(k), respectively, for k from 2 to kmax.

VAR

the data frame where the first and the second columns are the number of groups k and the variance of pkp_k, respectively, for k from 2 to kmax.

CVI

the data frame where the first and the second columns are the number of groups k and the original CVI(k)(k), respectively, for k from 2 to kmax.

opt.pt

a character string indicating whether the maximum or the minimum of CVI specifies the optimal number of groups ("min" or "max") that user select.

Author(s)

Nathakhun Wiroonsri and Onthada Preedasawakul

References

N. Wiroonsri, O. Preedasawakul, "A Bayesian cluster validity index", arXiv:2402.02162, 2024.

See Also

B2_data, B_TANG.IDX, B_WP.IDX, B_Wvalid, B_DB.IDX

Examples


# install a package for computing an underlying CVI
# install.packages("UniversalCVI")

library(UniversalCVI)
library(BayesCVI)

data = R1_data[,-3]

# Compute WP index by WP.IDX using default gamma
FCM.WP = WP.IDX(scale(data), cmax = 10, cmin = 2, corr = 'pearson', method = 'FCM', fzm = 2,
                iter = 100, nstart = 20, NCstart = TRUE)


# WP.IDX values
result = FCM.WP$WP$WPI


aalpha = c(20,20,20,5,5,5,0.5,0.5,0.5)
B.WP = BayesCVIs(CVI = result,
          n = nrow(data),
          kmax = 10,
          opt.pt = "max",
          alpha = aalpha,
          mult.alpha = 1/2)

# plot the BCVI

pplot = plot_BCVI(B.WP)
pplot$plot_index
pplot$plot_BCVI
pplot$error_bar_plot


[Package BayesCVI version 1.0.0 Index]