0
我想列出所有的預測。weka決策樹java
我有這樣的代碼:
//Get File
BufferedReader reader = new BufferedReader(new FileReader(PATH + "TempArffFile.arff"));
//Get the data
Instances data = new Instances(reader);
reader.close();
//Setting class attribute
data.setClassIndex(data.numAttributes() - 1);
//Make tree
J48 tree = new J48();
String[] options = new String[1];
options[0] = "-U";
tree.setOptions(options);
tree.buildClassifier(data);
//Print tree
System.out.println(tree);
它工作正常,我可以看到樹印,但不知道如何使用,從這裏工作。 我想爲每個根做一個清單,我該怎麼做?
那不是我想要的。 我有這個主題:title <= 1:bad(4.0) title> 1 | positionMatch <= 1 | | countryCode <= 1-> good | | countryCode> 1-> bad | positionMatch> 1->好。 現在我有一些項目,並希望檢查它是否好。 title = 2,position = 0,country code = 0 =>所以很好。我怎麼能在java中檢查? – igor 2014-09-30 08:58:03
你的意思是說你想要樹中的所有規則?我很抱歉,但問題似乎要求預測。 – 2014-09-30 11:59:43
我的錯誤我會問一個新的。你的代碼確實適用於預測 – igor 2014-09-30 14:19:44