[vtkusers] Get cluster centers from vtkKMeansStatistics

Philippe Pebay philippe.pebay at kitware.com
Tue Nov 22 11:09:23 EST 2011


Hello David

The cluster centers are given through the model output port of the k-means
engine.

Specifically, you can retrieve them as follows:

vtkMultiBlockDataSet* outputMetaDS
  = vtkMultiBlockDataSet::SafeDownCast( kmeans->GetOutputDataObject(
vtkStatisticsAlgorithm::OUTPUT_MODEL ) );

where kmeans is the vtkKMeansStatistics* previously executed.

The first block is a vtkTable created by the Learn operation, i.e., the
operation that executes as many clustering operations as requested, with
those values of k that were requested.
As a result, there is a row per Run ID and per cluster center.

For example, with a single run and k=3, one obtains the following:
+-----------------+-----------------+-----------------+-----------------+-----------------+-----------------+------------------+
| Run ID          | K               | Iterations      | Error           |
Cardinality     | coord 0         | coord 2          |
+-----------------+-----------------+-----------------+-----------------+-----------------+-----------------+------------------+
| 0               | 3               | 4               | 1.27871         |
19              | 0.226315        | 0.403089         |
| 0               | 3               | 4               | 1.08932         |
18              | 0.618059        | 0.744096         |
| 0               | 3               | 4               | 0.46612         |
13              | 0.73027         | 0.228617         |
+-----------------+-----------------+-----------------+-----------------+-----------------+-----------------+------------------+

I hope this helps. For more detail, you might want to have a look at the
SAND report which we wrote at the time:
  http://www.kitware.com/InfovisWiki/images/1/18/SAND2009-7855.pdf
or more generally www.kitware.com/InfovisWiki/index.php/Statistics_Engines

Please let me know should you have any other question. Thank you
Philippe


On Tue, Nov 22, 2011 at 4:23 PM, David Doria <daviddoria at gmail.com> wrote:

> I would like to know the resulting cluster centers after running
> vtkKMeansStatistics. I don't see an interface to do this - am I
> missing it? Or would I have to loop over all of the points and average
> the coordinates of points with a particular cluster id?
>
> Thanks,
>
> David
> _______________________________________________
> Powered by www.kitware.com
>
> Visit other Kitware open-source projects at
> http://www.kitware.com/opensource/opensource.html
>
> Please keep messages on-topic and check the VTK FAQ at:
> http://www.vtk.org/Wiki/VTK_FAQ
>
> Follow this link to subscribe/unsubscribe:
> http://www.vtk.org/mailman/listinfo/vtkusers
>



-- 
Philippe Pébay
Directeur de la Visualisation et du Calcul Haute Performance
Kitware SAS
20 rue de la Villette
69328 Lyon cedex 03, France
+33 (0)4.26.68.50.03
http://www.kitware.fr
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.vtk.org/pipermail/vtkusers/attachments/20111122/723b509e/attachment.htm>


More information about the vtkusers mailing list