예제 #1
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;
 }
예제 #2
0
 public void pruneRecursive(ClusNode node) {
   if (node.atBottomLevel()) {
     return;
   }
   for (int i = 0; i < node.getNbChildren(); i++) {
     ClusNode child = (ClusNode) node.getChild(i);
     pruneRecursive(child);
   }
   RegressionStat stat = (RegressionStat) node.getClusteringStat();
   double rmsLeaf = stat.getRMSE(m_ClusteringWeights);
   double adjustedErrorLeaf = rmsLeaf * pruningFactor(stat.getTotalWeight(), 1);
   double rmsSubTree =
       Math.sqrt(node.estimateClusteringSS(m_ClusteringWeights) / stat.getTotalWeight());
   double adjustedErrorTree =
       rmsSubTree * pruningFactor(stat.getTotalWeight(), node.getModelSize());
   // System.out.println("C leaf: "+rmsLeaf+" tree: "+rmsSubTree);
   // System.out.println("C leafadj: "+adjustedErrorLeaf +" treeadj: "+rmsSubTree);
   if ((adjustedErrorLeaf <= adjustedErrorTree)
       || (adjustedErrorLeaf < (m_GlobalDeviation * 0.00001))) {
     node.makeLeaf();
   }
 }