-2
我使用的訓練數據生成ML決策樹。根據我的使用情況,我需要查看決策樹以獲取有關數據分佈的更多詳細信息,例如每個節點處的值等。我使用java中的weka生成樹,然後使用簡單的print語句可以看到樹結構,但是weka沒有提供任何API來進一步查看樹,樹只能以String形式提供。我不想解析字符串,是否還有其他可用的庫,可以通過正常遍歷將樹翻譯爲一組規則? 任何其他基於ML的庫可以基於可用的數據生成樹,並讓您可以像規則提取一樣查看樹進行分析?遍歷決策樹得到的規則集
BufferedReader reader = new BufferedReader(
new FileReader("NewData.arff"));
Instances data = new Instances(reader);
reader.close();
data.setClassIndex(data.numAttributes() - 1);
String[] options = new String[1];
options[0] = "-U"; // unpruned tree
J48 tree = new J48(); // new instance of tree
tree.setOptions(options); // set the options
tree.setMinNumObj(100);
tree.buildClassifier(data); // build classifier
System.out.println(tree); // Print tree as string
現在我想窺視一下樹,得到一些結果。請幫助我完成任何可用的庫。