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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 4, 20262026-06-04T10:24:42+00:00 2026-06-04T10:24:42+00:00

Before I decided to post the problem I’m having I’ve read a lot of

  • 0

Before I decided to post the problem I’m having I’ve read a lot of posts and I still couldn’t get a clear answer. So here it is:

Using weka I have trained a NaiveBayesTree with my training data that looks like that:

(the values are simplified, and there's 20000 rows in the training set)
AF3,F7,F3,FC5,T7,T8,FC6,F4,F8,AF4,Action
-1,2,0,1,0,0,-1,-0,-0,-0,NEUTRAL
-2,1,0,2,-0,0,-0,0,-1,-0,RIGHT
-1,1,0,2,-0,0,-1,0,-1,-0,LEFT

Now I would like to use the saved model in my program to determine what is the class distribution in the given 128 rows of test data. For this 128 rows I do not have the classes (Action attribute) assigned. Basically I would like the model to answer that 🙂

So the test rows looks like this:

-1,1,0,2,-0,0,-1,0,-1,-0,?

So far I’ve came up with this code:

Classifier nbTree = (Classifier)SerializationHelper.read(Model) as NBTree;
Instances testInstances = TestSet();
testInstances.setClassIndex(10);

for (int i = 0; i < testInstances.numInstances(); i++)
{
    Instance instance = testInstances.instance(i);
    double assignedClass = nbTree.classifyInstance(instance);
    double[] distributionForInstance = nbTree.distributionForInstance(instance);
}

But it will always generate 0 for each assignedClass and distributionForInstance will always have exactly one element with different values:

0,9412543332996
0,9412543332996
0,9412543332996
0,9412543332996
0,0577106296809467
0,315216251505317
0,9412543332996
0,9412543332996
0,315216251505317
0,315216251505317
0,863366140658458
0,9412543332996
0,9412543332996
0,9412543332996
0,9412543332996
0,783615619462732

I walking in circles fro two days now and would really appreciate some help 🙂

  • 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-04T10:24:45+00:00Added an answer on June 4, 2026 at 10:24 am

    I did some more research and came across this article: http://weka.wikispaces.com/Making+predictions which helped me to write the following code:

    Classifier nbTree = (Classifier)SerializationHelper.read(Model) as NBTree;
    Instances testDataSet = new Instances(new BufferedReader(new FileReader(arff)));
    testDataSet.setClassIndex(10);
    Evaluation evaluation = new Evaluation(testDataSet);
    
    for (int i = 0; i < testDataSet.numInstances(); i++)
    {
        Instance instance = testDataSet.instance(i);
        evaluation.evaluateModelOnceAndRecordPrediction(nbTree, instance);
    }
    
    foreach (object o in evaluation.predictions().toArray())
    {
        NominalPrediction prediction = o as NominalPrediction;
        if (prediction != null)
        {
            double[] distribution = prediction.distribution();
            double predicted = prediction.predicted();
        }
    }
    

    This code allows me to check what class is being predicted on a given instance as well as the probability values of all of the classes that were taken under consideration.
    I hope this will help someone 🙂

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I read a lot of documentation about this before i decided to ask. So
Before Django 1.0 there was an easy way to get the admin url of
Before someone said that I did not read I may say that I read
I recently ran into a quite complex problem and after looking around a lot
I decided that my client would be overwhelmed by a lot of bells and
This question to which I already found the answer is posted here in case
Here's my problem: I have to call a web service with a secure header
First post here: -Deep Breath- In order to 'windowise' an app that works pretty
I've decided to completely rewrite my old PHP project from the ground up. Before,
I started to ask this question and then figured out the answer before submitting

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.