weka:如何通过测试单个实例来获取类名 [英] weka: how to get class name from testing single instance

查看:191
本文介绍了weka:如何通过测试单个实例来获取类名的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想对单个实例进行单一测试

i want to make a single test for single instance

我在FilteredClassifier中使用j48,如下所示:

i use j48 in FilteredClassifier like this:

Remove rm = new Remove();
rm.setAttributeIndices("1"); // remove 1st attribute
// classifier
J48 j48 = new J48();
j48.setUnpruned(true); // using an unpruned J48

// meta-classifier
FilteredClassifier fc_J48 = new FilteredClassifier();
fc_J48.setFilter(rm);
fc_J48.setClassifier(j48);
tdta.dataSet.setClassIndex(tdta.dataSet.numAttributes() - 1);
fc_J48.buildClassifier(tdta.dataSet);

现在,我尝试这些选项:

now, i try those options:

j48.classifyInstance(dataSet.instance(1))

eval.evaluateModelOnce(j48, dataSet.instance(1))

我认为这将是相同的结果。

i think it's will be the same result.

我的问题是:
当我得到双号时,我怎样才能将它翻译成班级名称?

my question is: when i get the double number, how can i translate it to the class name ?

推荐答案

试试这个:

System.out.println(dataSet.classAttribute().value((int) j48.classifyInstance(dataSet.instance(1)));

看看: http://weka.8497.n7.nabble.com/Predicting-in-java-td27363.html

这篇关于weka:如何通过测试单个实例来获取类名的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆