Output of the RandomSubSpace Weka API classifier in Java

I built the RandomSubSpace classifier in a weka server, and now I use it with the weka Java interface, however, when I run distibutionForInstance (), I get an array with 1.0 as the first value and 0.0 as all rest. I am trying to get a numerical prediction, not a class. Is there another function that I should use, or another option in the ForInstance distribution? Code snippet below:

Classifier cls = (classifier) ​​weka.core.SerializationHelper.read ("2015-09-6 Random Subpace Model.model");

Instances originalTrain = new DataSource ("Instances.arff"). getDataSet ();

         int cIdx=originalTrain.numAttributes()-1;
         originalTrain.setClassIndex(cIdx);


         int s1=1;  


         double value=cls.classifyInstance(originalTrain.instance(s1));


         double[] percentage=cls.distributionForInstance(originalTrain.instance(s1));



         System.out.println("The predicted value of instance "+Integer.toString(s1) +"Value: " + percentage[1]); 
         System.out.println(Arrays.toString(percentage));

, : 1Value: 0.0 [1,0, 0,0, 0,0, 0,0, 0,0, 0,0, 0,0, 0,0, 0,0, 0,0, 0,0, 0,0, 0,0, 0,0, 0,0, 0,0, 0,0, 0,0, 0,0, 0,0, 0,0, 0,0, 0,0, 0,0, 0,0, 0,0, 0,0, 0,0, 0,0, 0,0, 0,0, 0,0, 0,0, 0,0, 0,0, 0,0, 0,0, 0,0] >

- , , weka explorer?

.

0
2

. :

originalTrain.classAttribute().value((int) cls.classifyInstance(originalTrain.instance(s1))))

0

:

classif.distributionForInstance(instance);

. 1.0 hte 0.0, , . , .

0

Source: https://habr.com/ru/post/1622597/


All Articles