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

  • Home
  • SEARCH
  • 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 8954947
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 15, 20262026-06-15T14:25:47+00:00 2026-06-15T14:25:47+00:00

I have a simple naive bayes classifier from WEKA. I’m using a directory structure

  • 0

I have a simple naive bayes classifier from WEKA. I’m using a directory structure and reading it in via the TextDirectoryLoader. The Directory structure is

Training_Data
     Spam (folder)
         text files
     Ham (folder)
         text files

I can get the distributions like this

for(Instance i: testInstances){

    double [] distributions = classifier.distributionForInstance(i);
    for(double d : distributions)
        System.out.println(d);
}

what I want to do is get the category name to go along side the distribution so I can print it out like so

System.out.println("Category: "+/*something to get the category name*/+ ":"+ d);

I’ve been looking around for hours now and can’t figure out how to do it. Anyone know how?

  • 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-15T14:25:49+00:00Added an answer on June 15, 2026 at 2:25 pm

    You can use instance.classAttribute().value(valIndex) where valIndex is the index of the category:

    for(Instance i: testInstances){
      double [] distributions = classifier.distributionForInstance(i);
      for(int index = 0; index < distributions.length; index++)
          System.out.println(i.classAttribute().value(index) + ": " + distributions[index]);
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I start using NaiveBayes/Simple classifier for classification (Weka), however I have some problems to
Does anybody have any pointers to Naive Bayes Classifier Implementation preferably in C. I
I am attempting to implement a Naive Bayes classifier using BNT and MATLAB. So
CouchDB, version 0.10.0, using native erlang views. I have a simple document of the
I'm using the explorer feature of Weka for classification. So I have my .arff
I have this simple structure: 1 parent, and two different childs. public class Parent{}
How do I save a trained Naive Bayes classifier to disk and use it
I have a simple data model and I am using EF4.1 code first (but
When trying to fit Naive Bayes: training_data = sample; % target_class = K8; #
I have a relatively simple application which I need to make native Mac OSX

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.