The Altair Community is migrating to a new platform to provide a better experience for you. The RapidMiner Community will merge with the Altair Community at the same time. In preparation for the migration, both communities are on read-only mode from July 15th - July 24th, 2024. Technical support via cases will continue to work as is. For any urgent requests from Students/Faculty members, please submit the form linked here.

"How to output the centroids of K-Means Clusters"

Legacy UserLegacy User Member Posts: 0 Newbie
edited May 2019 in Help

I wanna get the output of the clusters' centroids through Java code. I have 10 clusters and about 10,000 attributes. So for each cluster, there should be a row with about 10,000 numbers. 

Does anybody know how should I do that in Java? Which operator should I use?

thanks beforehand,



  • Options
    IngoRMIngoRM Administrator, Moderator, Employee, RapidMiner Certified Analyst, RapidMiner Certified Expert, Community Manager, RMResearcher, Member, University Professor Posts: 1,751 RM Founder
    Hi Qian,

    I am assuming that you are familiar with the general way how to use RapidMiner from your Java applications. If not, please read the written tutorial (available from our download page), especially the last two chapters and search in both forums for hints for integration.

    Let's say you managed to load your data set and have them stored in a ExampleSet object called "exampleSet". Then you should try something like

    ExampleSet exampleSet = null; // load your data here
    Operator kMeans = OperatorService.createOperator(KMeans.class);
    CentroidBasedClusterModel clusterModel = (CentroidBasedClusterModel) kMeans.apply(new IOContainer(exampleSet));

    for (int i = 0; i < clusterModel.getNumberOfClusters(); i++) {
    double[] location = clusterModel.getCentroid(i);
    // do whatever you want with the centroid
    Hope that helps,
  • Options
    Legacy UserLegacy User Member Posts: 0 Newbie
    Thanks a lot. It's quite helpful.

Sign In or Register to comment.