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 8273749
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 8, 20262026-06-08T07:33:47+00:00 2026-06-08T07:33:47+00:00

What is the majority vote algorithm used in Weka. I tried to figure out

  • 0

What is the majority vote algorithm used in Weka. I tried to figure out its code but could not understand it.

  • 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-06-08T07:33:48+00:00Added an answer on June 8, 2026 at 7:33 am

    In Weka you can select multiple classifiers to be used in Weka.classifiers.meta.vote. If you select Majority Voting as combinationRule (which only works with nominal classes), then each of these classifiers will predict a nominal class label for a test sample. The label which was predicted the most will then be selected as output of the vote classifier.

    For example. You select the following classifiers to be used: trees.J48, bayes.NaiveBayes and functions.LibSVM to predict the weather, which can be labelled bad, normal or good. Given a new test sample, these are their predictions:

    J48        - bad
    NaiveBayes - good
    LibSVM     - good
    

    The results in the following votes for each possible label:

    bad    - 1
    normal - 0
    good   - 2
    

    So Weka’s vote classifier will select good as label for the test sample, because it has the most votes amongst all three classifiers.

    –Edit–

    The function distributionForInstanceMajorityVoting in the source code of Weka’s Vote class shows you how the majority voting is implemented. I added the function below. Here is a description of what it does:

    The code works pretty much as I explained above. All nominal classes of the test instance are loaded into votes. Each classifier classifies the instance and the label with the highest probability gets a vote. If multiple labels have the same probability then all these labels receive a vote. Once all classifiers have cast there vote, the label with the most votes is selected as the label for the test instance. If multiple labels have the same amount of votes, then one of these labels will randomly be selected.

    protected double[] distributionForInstanceMajorityVoting(Instance instance) throws Exception {
    
      double[] probs = new double[instance.classAttribute().numValues()];
      double[] votes = new double[probs.length];
    
      for (int i = 0; i < m_Classifiers.length; i++) {
        probs = getClassifier(i).distributionForInstance(instance);
        int maxIndex = 0;
        for(int j = 0; j<probs.length; j++) {
          if(probs[j] > probs[maxIndex])
            maxIndex = j;
        }
    
        // Consider the cases when multiple classes happen to have the same probability
        for (int j=0; j<probs.length; j++) {
          if (probs[j] == probs[maxIndex])
            votes[j]++;
        }
      }
    
      for (int i = 0; i < m_preBuiltClassifiers.size(); i++) {
        probs = m_preBuiltClassifiers.get(i).distributionForInstance(instance);
        int maxIndex = 0;
    
        for(int j = 0; j<probs.length; j++) {
          if(probs[j] > probs[maxIndex])
            maxIndex = j;
        }
    
        // Consider the cases when multiple classes happen to have the same probability
        for (int j=0; j<probs.length; j++) {
          if (probs[j] == probs[maxIndex])
            votes[j]++;
        }
      }
    
      int tmpMajorityIndex = 0;
      for (int k = 1; k < votes.length; k++) {
        if (votes[k] > votes[tmpMajorityIndex])
          tmpMajorityIndex = k;
      }
    
      // Consider the cases when multiple classes receive the same amount of votes
      Vector<Integer> majorityIndexes = new Vector<Integer>();
      for (int k = 0; k < votes.length; k++) {
        if (votes[k] == votes[tmpMajorityIndex])
          majorityIndexes.add(k);
       }
    
      // Resolve the ties according to a uniform random distribution
      int majorityIndex = majorityIndexes.get(m_Random.nextInt(majorityIndexes.size()));
    
      //set probs to 0
      probs = new double[probs.length];
    
      probs[majorityIndex] = 1; //the class that have been voted the most receives 1
    
      return probs;
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I see the majority of WPF Ribbon examples out there use some code like
I find majority teaching online is about 2 button beside each other but I
For the majority of my site, I want to require login. But for two
NOTE: I have solved the majority of this problem but have run into a
What are the standard user role names that a majority of sites could all
A majority of my work has all been in .net, but this project was
The title speaks to the majority of the question, but I'm having a hard
I am using Majority voting combination rule in weka. There are 4 classifiers in
I am debugging someone else's JavaScript code and a majority of the code is
I'm renaming the majority of the variables in a data frame and I'm not

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.