Calculate dunn index for Kernel Kmeans in r -



Calculate dunn index for Kernel Kmeans in r -

i ran kmeans on info using:

spherical_data <- kmeans(mydata,4)

now calculate dunn index used:

spherical_data <- kmeans(mydata,4) dist <- dist(mydata,method="euclidean") dunn(dist, spherical_data$cluster)

here sec argument dunn function vector contains cluster memberships of points in mydata.

now ran kernalized kmeans follows:

kernel_kmeans <- kkmeans(mydata, centers=4, kernel = "rbfdot", kpar = "automatic")

kernel_kmeans gives me next output:

spectral clustering object of class "specc" cluster memberships: 3 1 3 3 3 2 3 3 2 3 2 2 3 2 1 4 3 1 2 1 3 3 4 2 2 1 1 2 3 3 2 1 4 1 2 3 3 2 3 4 2 2 3 1 1 3 2 2 3 3 1 3 3 1 1 2 1 4 4 3 3 3 3 4 3 3 3 3 3 2 1 3 1 2 3 2 4 3 1 2 3 2 4 2 3 2 1 3 3 4 2 3 2 3 1 2 3 4 2 3 2 4 1 2 1 1 2 1 2 1 1 3 3 3 3 2 3 3 1 1 1 2 1 4 1 1 3 3 2 4 3 3 1 3 1 2 1 2 1 2 3 1 1 1 3 3 4 2 1 3 1 1 3 3 3 3 3 2 2 gaussian radial basis kernel function. hyperparameter : sigma = 7.63469658003494 centers: [,1] [,2] [1,] 0.03108416 -0.2142212 [2,] -0.63034038 -0.6909727 [3,] 0.69360916 0.3623118 [4,] -0.95418284 0.1941879 cluster size: [1] 287 209 389 115 within-cluster sum of squares: [1] 286.34824 27.35574 188.54685 158.99104

to calculate dunn index need first output i.e vector containing cluster membership of points (marked under cluster memberships).

dunn(dist, kernel_kmeans$cluster) not work.

can tell me how done.

here's approach extract cluster info object returned kkmeans.

an example:

library(kernlab) data(iris) sc <- kkmeans(as.matrix(iris[,-5]), centers=3)

the output (sc):

spectral clustering object of class "specc" cluster memberships: 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 2 2 2 3 2 3 2 3 2 3 3 3 3 2 3 2 3 3 2 3 2 3 2 2 2 2 2 2 2 3 3 3 3 2 3 2 2 3 3 3 3 2 3 3 3 3 3 3 3 3 2 2 2 2 2 2 3 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 gaussian radial basis kernel function. hyperparameter : sigma = 0.957009094923757 centers: [,1] [,2] [,3] [,4] [1,] 5.006000 3.428000 1.462000 0.246000 [2,] 6.554286 2.974286 5.300000 1.865714 [3,] 5.580000 2.633333 3.986667 1.233333 cluster size: [1] 50 70 30 within-cluster sum of squares: [1] 1313.240 2004.637 625.704

you can utilize @.data extract information:

sc@.data # [1] 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 # [39] 1 1 1 1 1 1 1 1 1 1 1 1 2 2 2 3 2 3 2 3 2 3 3 3 3 2 3 2 3 3 2 3 2 3 2 2 2 2 # [77] 2 2 2 3 3 3 3 2 3 2 2 3 3 3 3 2 3 3 3 3 3 3 3 3 2 2 2 2 2 2 3 2 2 2 2 2 2 2 # [115] 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2

r

Comments

Popular posts from this blog

formatting - SAS SQL Datepart function returning odd values -

c++ - Apple Mach-O Linker Error(Duplicate Symbols For Architecture armv7) -

php - Yii 2: Unable to find a class into the extension 'yii2-admin' -