0
votes

I want to run the naieve bayes classifier. I have trained this model in weka. Now for each testing instances I want to find the predicted class and the probability distribution so that with this value I can rank the instances as well. I am running the weka from java. How can i get the probability distribution in weka java?

1

1 Answers

2
votes
double[] predictionDistribution = null;
    try {
        double clsLabel = classifier.classifyInstance(Test Instance Here);
        predictionDistribution = classifier.distributionForInstance(Test Instance Here);
    } catch (Exception e) {
        System.out.println("Unable to classify item\n");
    }

Use a double[] array and then use your classifier's distributionForInstance() method.