Example #1
0
 public final void printTree(PrintWriter writer, String prefix) {
   int lvc = 0;
   for (int i = 0; i < m_Folds.length; i++) {
     ClusNode node = m_Nodes[i];
     if (!node.hasBestTest()) {
       if (lvc != 0) writer.print(", ");
       writer.print(m_Folds[i] + ": ");
       writer.print(ClusFormat.ONE_AFTER_DOT.format(node.getTotWeight()));
       lvc++;
     }
   }
   if (lvc > 0) {
     writer.print(" ");
     showPath(getPath(), writer);
   }
   int nb = getNbChildren();
   if (nb > 0) {
     if (lvc > 0) {
       writer.println();
       writer.print(prefix);
     }
   } else {
     writer.println();
   }
   for (int i = 0; i < nb; i++) {
     OptXValSplit split = (OptXValSplit) getChild(i);
     if (i != 0) {
       writer.println(prefix + "|  ");
       writer.print(prefix);
     }
     writer.print("G" + i + " ");
     writer.print(MyIntArray.print(split.getFolds()));
     writer.print(" - ");
     writer.print(split.getTest().getString());
     writer.println();
     int mb = split.getNbChildren();
     String gfix = (i != nb - 1) ? "|  " : "   ";
     for (int j = 0; j < mb; j++) {
       OptXValNode node = (OptXValNode) split.getChild(j);
       String suffix = (j != mb - 1) ? "|      " : "       ";
       if (j == 0) writer.print(prefix + gfix + "+-yes: ");
       else {
         writer.println(prefix + gfix + "|");
         writer.print(prefix + gfix + "+-no:  ");
       }
       node.printTree(writer, prefix + gfix + suffix);
     }
   }
   writer.flush();
 }
Example #2
0
 public final ClusNode getTree(int fold) {
   int idx = Arrays.binarySearch(m_Folds, fold);
   ClusNode node = m_Nodes[idx];
   if (node.hasBestTest() && node.atBottomLevel()) {
     OptXValSplit split = null;
     int nb = getNbChildren();
     for (int i = 0; i < nb; i++) {
       OptXValSplit msplit = (OptXValSplit) getChild(i);
       if (msplit.contains(fold)) {
         split = msplit;
         break;
       }
     }
     int arity = node.updateArity();
     for (int i = 0; i < arity; i++) {
       OptXValNode subnode = (OptXValNode) split.getChild(i);
       node.setChild(subnode.getTree(fold), i);
     }
   }
   return node;
 }