本文整理汇总了Java中weka.gui.treevisualizer.TreeBuild类的典型用法代码示例。如果您正苦于以下问题:Java TreeBuild类的具体用法?Java TreeBuild怎么用?Java TreeBuild使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
TreeBuild类属于weka.gui.treevisualizer包,在下文中一共展示了TreeBuild类的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。
示例1: parse
点赞 2
import weka.gui.treevisualizer.TreeBuild; //导入依赖的package包/类
/**
* Parse the J48 tree model with supplementary information about weka attributes from the header.
* Each Disjunction in Disjunctive Normal Form (DNF).
* @param cModel J48 tree model to parse
* @param header to reference Weka Attributes
* @return Map of Disjunctions of traces for each class value
* @throws Exception
*/
@SuppressWarnings("unchecked")
public static Map<String, DNF> parse(J48 cModel, Instances header) throws Exception {
Map<String, DNF> valueTraces = new HashMap<String, DNF>();
// get tree node structure from model
Reader treeDot = new StringReader(cModel.graph());
TreeBuild treeBuild = new TreeBuild();
Node treeRoot = treeBuild.create(treeDot);
// set up one disjunction per class value
Attribute classAttr = header.classAttribute();
Enumeration<String> values = classAttr.enumerateValues();
while (values.hasMoreElements()) {
valueTraces.put(values.nextElement(), new DNF());
}
// recursively parse
parse(
treeRoot, header,
new Reason(),
valueTraces
);
// each Disjunction is naturally in DNF according to parsing process
return valueTraces;
}
开发者ID:claudiotrindade,
项目名称:contexttoolkit,
代码行数:36,
代码来源:J48Parser.java
示例2: findTreePath
点赞 2
import weka.gui.treevisualizer.TreeBuild; //导入依赖的package包/类
/**
* Parse the tree model to find the tree path
* @param instance Instance whose tree path need to be computed
* @param attsList the list of Attributes
* @param cModel the J48 current model
* @return String that keeps the tree path found
* @throws Exception
*/
public static String findTreePath(Instance instance,List<Attribute> attsList,J48 cModel) throws Exception{
//re-initialize check variable for the new instance
check=false;
//define the pathToResult var that keeps the path computed
List<String> pathToResult = new ArrayList<String>();
//attributes var
atts=attsList;
//define the tree details
Reader treeDot = new StringReader(((J48) cModel).graph());
TreeBuild treeBuild = new TreeBuild();
Node treeRoot = treeBuild.create(treeDot);
//recursively parse the tree model
findTreePath(treeRoot,instance,pathToResult);
//integrate the separate strings into one String
StringBuilder sb = new StringBuilder();
for (int j=0;j<pathToResult.size();j++){
sb.append((j+1)+" "+pathToResult.get(j)+"\n");
}
String result = sb.toString();
return result;
}
开发者ID:socialsensor,
项目名称:computational-verification,
代码行数:35,
代码来源:J48Parser.java