[R] clusterCrit package produces Nan
I'm trying to compute the Silhouette value of a clustering partition done with SOM method using the function intCriteria of the clusterCrit package but it returns me a Nan value: somebody knows why? To simplify my case, here there is an example: test [,1] [,2] [,3] [,4] [,5] [,6] [1,] 37.28577 8.902218 17.93830 38.80381 6.825286 18.44061 [2,] 37.25598 8.693962 18.09256 38.81784 7.005092 18.17899 [3,] 37.54612 8.262074 18.07639 38.87837 6.592799 18.31604 [4,] 37.56661 8.651182 17.98653 38.76980 6.596529 18.46937 [5,] 37.59454 8.546921 17.93558 39.00177 6.508707 18.40102 [6,] 37.62195 8.422909 18.03132 38.86634 7.024104 18.30201 [7,] 37.19365 8.662608 18.01295 38.37456 7.173594 18.24273 [8,] 37.63161 8.495688 18.05909 38.92736 6.884675 18.44871 [9,] 37.30077 8.488438 18.02636 38.60844 7.004214 18.45600 [10,] 37.52518 8.610817 18.00498 38.57547 6.877532 18.36552 datissimi = som(test, grid=somgrid(xdim=2, ydim=4, topo='rectangular'), rlen=500, keep.data=T) somissimo = datissimi$unit.classif intCriteria(test, somissimo, Silhouette) $silhouette [1] NaN Thanks, Paola __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] clusterCrit package produces Nan
Hello, Your example is difficult to reproduce. Please 1. use dput() to attach data 2. indicate the package(s) you used. There are at least 3 packages with a som function. It seems you used RSNNS. And when I run your code, there is no unit.classif in datissimi datissimi$unit.classif NULL Regards, Pascal On 30 January 2014 01:39, Paola Tellaroli paola.tellar...@gmail.com wrote: I'm trying to compute the Silhouette value of a clustering partition done with SOM method using the function intCriteria of the clusterCrit package but it returns me a Nan value: somebody knows why? To simplify my case, here there is an example: test [,1] [,2] [,3] [,4] [,5] [,6] [1,] 37.28577 8.902218 17.93830 38.80381 6.825286 18.44061 [2,] 37.25598 8.693962 18.09256 38.81784 7.005092 18.17899 [3,] 37.54612 8.262074 18.07639 38.87837 6.592799 18.31604 [4,] 37.56661 8.651182 17.98653 38.76980 6.596529 18.46937 [5,] 37.59454 8.546921 17.93558 39.00177 6.508707 18.40102 [6,] 37.62195 8.422909 18.03132 38.86634 7.024104 18.30201 [7,] 37.19365 8.662608 18.01295 38.37456 7.173594 18.24273 [8,] 37.63161 8.495688 18.05909 38.92736 6.884675 18.44871 [9,] 37.30077 8.488438 18.02636 38.60844 7.004214 18.45600 [10,] 37.52518 8.610817 18.00498 38.57547 6.877532 18.36552 datissimi = som(test, grid=somgrid(xdim=2, ydim=4, topo='rectangular'), rlen=500, keep.data=T) somissimo = datissimi$unit.classif intCriteria(test, somissimo, Silhouette) $silhouette [1] NaN Thanks, Paola __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. -- Pascal Oettli Project Scientist JAMSTEC Yokohama, Japan __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] clusterCrit package produces Nan
Hello, Please also reply to the list. I am not really familiar with this calculation, but it is maybe due to the fact you defined 8 nodes for your SOM, but your original data are only classified within 3 nodes. datissimi = som(test, grid=somgrid(xdim=2, ydim=4, topo='rectangular'), rlen=500, keep.data=TRUE) somissimo = datissimi$unit.classif unique(somissimo) [1] 2 4 8 intCriteria(test, somissimo, silhouette) $silhouette [1] NaN If I modify the shape of the Kohonen map: datissimi = som(test, grid=somgrid(xdim=3, ydim=1, topo='rectangular'), rlen=500, keep.data=TRUE) somissimo = datissimi$unit.classif unique(somissimo) [1] 1 2 3 intCriteria(test, somissimo, silhouette) $silhouette [1] 0.6478154 Hope this helps, Pascal On 30 January 2014 10:58, Paola Tellaroli paola.tellar...@gmail.com wrote: Hello Pascal, you're right, sorry. The package I used for the som function is kohonen, while data are: dput(test) structure(c(37.28577, 8.902218, 17.9383, 38.80381, 6.825286, 18.44061, 37.25598, 8.693962, 18.09256, 38.81784, 7.005092, 18.17899, 37.54612, 8.262074, 18.07639, 38.87837, 6.592799, 18.31604, 37.56661, 8.651182, 17.98653, 38.7698, 6.596529, 18.46937, 37.59454, 8.546921, 17.93558, 39.00177, 6.508707, 18.40102, 37.62195, 8.422909, 18.03132, 38.86634, 7.024104, 18.30201, 37.19365, 8.662608, 18.01295, 38.37456, 7.173594, 18.24273, 37.63161, 8.495688, 18.05909, 38.92736, 6.884675, 18.44871, 37.30077, 8.488438, 18.02636, 38.60844, 7.004214, 18.456, 37.52518, 8.610817, 18.00498, 38.57547, 6.877532, 18.36552), .Dim = c(10L, 6L)) Thank you, Paola On 29/gen/2014, at 20:25, Pascal Oettli wrote: -- Pascal Oettli Project Scientist JAMSTEC Yokohama, Japan -- Pascal Oettli Project Scientist JAMSTEC Yokohama, Japan __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.