Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7601899
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 30, 20262026-05-30T23:16:30+00:00 2026-05-30T23:16:30+00:00

I have what feels like a simple problem, but I can’t seem to find

  • 0

I have what feels like a simple problem, but I can’t seem to find an answer. I’m pretty new to Weka, but I feel like I’ve done a bit of research on this (at least read through the first couple of pages of Google results) and come up dry.

I am using Weka to run clustering using Simple K-Means. In the results list I have no problem visualizing my output (“Visualize cluster assignments”) and it is clear both from my understanding of the K-Means algorithm and the output of Weka that each of my instances is ending up as a member of a different cluster (centered around a particular centroid, if you will).

I can see something of the cluster composition from the text output. However Weka provides me with no explicit “mapping” from instance number to cluster number. I would like something like:

instance 1 --> cluster 0
instance 2 --> cluster 0
instance 3 --> cluster 2
instance 4 --> cluster 1
... etc.

How do I obtain these results without calculating the distance from each item to each centroid on my own?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-30T23:16:32+00:00Added an answer on May 30, 2026 at 11:16 pm

    I had the same problem and figured it out. I am posting the method here if anyone needs to know :

    Its actually quite simple, you have to use Weka’s java api.

    SimpleKMeans kmeans = new SimpleKMeans();
    
    kmeans.setSeed(10);
    
    // This is the important parameter to set
    kmeans.setPreserveInstancesOrder(true);
    kmeans.setNumClusters(numberOfClusters);
    kmeans.buildClusterer(instances);
    
    // This array returns the cluster number (starting with 0) for each instance
    // The array has as many elements as the number of instances
    int[] assignments = kmeans.getAssignments();
    
    int i=0;
    for(int clusterNum : assignments) {
        System.out.printf("Instance %d -> Cluster %d", i, clusterNum);
        i++;
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am pretty new to Haskell but I feel like I have a decent
I feel like GUID/UUID questions have been done to death here, but I can't
I feel like the answer to this question is really simple, but I really
I have a rather simple question for you.. I feel like I should have
I have a relationship in a Core Data model that feels like it wants
I feel like this is quite delicate, I have various folders whith projects I
I have a question that I just don't feel like I've found a satisfactory
Say I don't have mod_deflate compiled into apache, and I don't feel like recompiling
Some development skills, like refactoring operations, feel like they have an almost unlimited pontential
I am very new to Git and I have a slight problem. In SVN

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.