/** * Returns the tree as if-then statements. * * @param className the name for the generated class * @return the tree as a Java if-then type statement * @throws Exception if something goes wrong */ @Override public String toSource(String className) throws Exception { if (m_Tree == null) { throw new Exception("REPTree: No model built yet."); } StringBuffer[] source = m_Tree.toSource(className, m_Tree); return "class " + className + " {\n\n" + " public static double classify(Object [] i)\n" + " throws Exception {\n\n" + " double p = Double.NaN;\n" + source[0] // Assignment code + " return p;\n" + " }\n" + source[1] // Support code + "}\n"; }
/** * Returns the tree as if-then statements. * * @param className the name for the generated class * @return the tree as a Java if-then type statement * @throws Exception if something goes wrong */ @Override public String toSource(String className) throws Exception { if (m_Tree == null) { throw new Exception("REPTree: No model built yet."); } StringBuffer[] source = m_Tree.toSource(className, m_Tree); return "class " + className + " {\n\n" + " public static double classify(Object [] i)\n" + " throws Exception {\n\n" + " double p = Double.NaN;\n" + source[0] // Assignment code + " return p;\n" + " }\n" + source[1] // Support code + "}\n"; }
StringBuffer[] sub = m_Successors[i].toSource(className, this); text.append("" + sub[0]); atEnd.append("" + sub[1]);
StringBuffer[] sub = m_Successors[i].toSource(className, this); text.append("" + sub[0]); atEnd.append("" + sub[1]);