forum.alglib.net http://forum.alglib.net/ |
|
K-means clustering: finding out number of clustered elements http://forum.alglib.net/viewtopic.php?f=2&t=2248 |
Page 1 of 1 |
Author: | maksims [ Sun Feb 22, 2015 7:34 pm ] |
Post subject: | K-means clustering: finding out number of clustered elements |
I'm trying to create a "heat map" from a large dataset of coordinates, where clustering fits just fine. The k-means++ clustering example works OK, but I need not only mean coordinates based on K (stored in kmeansreport.c array), but also total number of original elements for each resulting coordinate: Code: Dim xy(4, 1) As Double xy(0, 0) = 1 : xy(0, 1) = 1 xy(1, 0) = 1 : xy(1, 1) = 2 xy(2, 0) = 4 : xy(2, 1) = 1 xy(3, 0) = 2 : xy(3, 1) = 3 xy(4, 0) = 4 : xy(4, 1) = 1.5 Dim s As alglib.clusterizerstate = Nothing Dim rep As alglib.kmeansreport = Nothing alglib.clusterizercreate(s) alglib.clusterizersetpoints(s, xy, 2) alglib.clusterizersetkmeanslimits(s, 5, 0) alglib.clusterizerrunkmeans(s, 2, rep) Now it's possible to inspect rep.c and find out resulting coordinate pairs: Code: System.Console.WriteLine("X=" + rep.c(0, 0).ToString + ", Y=" + rep.c(0, 1).ToString) System.Console.WriteLine("X=" + rep.c(1, 0).ToString + ", Y=" + rep.c(1, 1).ToString) But, how do I compute total number of original xy elements "behind" each rep.c coordinate? When I create a heat map I need x,y and "weight" value - how do I find one? Regards, Maksim Sestic |
Page 1 of 1 | All times are UTC |
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group http://www.phpbb.com/ |