【发布时间】:2015-12-08 16:34:24
【问题描述】:
我已经在 weka exploer 中构建了一个 RandomSubSpace 分类器,现在正尝试将它与 weka Java API 一起使用,但是,当我运行 distibutionForInstance() 时,我得到一个数组,其中 1.0 作为第一个值,0.0 作为所有休息。我试图得到数值预测而不是类。是否有我应该使用的不同功能或distributionForInstance上的不同选项?下面的代码片段:
Classifier cls = (Classifier) weka.core.SerializationHelper.read("2015-09-6 Random Subspace 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, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0]
有人知道如何像我在 weka explorer 中那样获得数值输出吗?
提前致谢。
【问题讨论】:
标签: java machine-learning weka