View source: R/clustering_evaluation.R
calcNegentropyI | R Documentation |
Calculate the Negentropy Increment index of clustering quality.
calcNegentropyI(data, belongmatrix, centers)
data |
The original dataframe used for the clustering (n*p) |
belongmatrix |
A membership matrix (n*k) |
centers |
The centres of the clusters |
The Negentropy Increment index \insertCiteda2020incrementalgeocmeans is based on the assumption that a normally shaped cluster is more desirable. It uses the difference between the average negentropy of all the clusters in the partition, and that of the whole partition. A smaller value indicates a better partition. The formula is:
NI=\frac{1}{2} \sum_{j=1}^{k} p_{i} \ln \left|{\boldsymbol{\Sigma}}_{j}\right|-\frac{1}{2} \ln \left|\boldsymbol{\Sigma}_{d a t a}\right|-\sum_{j=1}^{k} p_{j} \ln p_{j}
with a cluster, |.| the determinant of a matrix,
j a cluster
|.| the determinant of a matrix
\left|{\boldsymbol{\Sigma}}_{j}\right|
the covariance matrix of the dataset weighted by the membership values to cluster j
\left|\boldsymbol{\Sigma}_{d a t a}\right|
the covariance matrix of the dataset
p_{j}
the sum of the membership values to cluster j divided by the number of observations.
A float: the Negentropy Increment index
data(LyonIris)
AnalysisFields <-c("Lden","NO2","PM25","VegHautPrt","Pct0_14","Pct_65","Pct_Img",
"TxChom1564","Pct_brevet","NivVieMed")
dataset <- sf::st_drop_geometry(LyonIris[AnalysisFields])
queen <- spdep::poly2nb(LyonIris,queen=TRUE)
Wqueen <- spdep::nb2listw(queen,style="W")
result <- SFCMeans(dataset, Wqueen,k = 5, m = 1.5, alpha = 1.5, standardize = TRUE)
calcNegentropyI(result$Data, result$Belongings, result$Centers)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.