@Override public void onCompletion(CountedCompleter caller) { ScoreBuildHistogram sbh = (ScoreBuildHistogram) caller; // System.out.println(sbh.profString()); final int leafk = _leafs[_k]; int tmax = _tree.len(); // Number of total splits in tree K for (int leaf = leafk; leaf < tmax; leaf++) { // Visit all the new splits (leaves) DTree.UndecidedNode udn = _tree.undecided(leaf); // System.out.println((_st._nclass==1?"Regression":("Class // "+_fr2.vecs()[_st._ncols].domain()[_k]))+",\n Undecided node:"+udn); // Replace the Undecided with the Split decision DTree.DecidedNode dn = _st.makeDecided(udn, sbh._hcs[leaf - leafk]); // System.out.println(dn + // " > Split: " + dn._split + " L/R:" + dn._split._n0+" + // "+dn._split._n1); if (dn._split._col == -1) udn.do_not_split(); else { _did_split = true; DTree.Split s = dn._split; // Accumulate squared error improvements per variable AtomicUtils.FloatArray.add(_improvPerVar, s.col(), (float) (s.pre_split_se() - s.se())); } } _leafs[_k] = tmax; // Setup leafs for next tree level int new_leafs = _tree.len() - tmax; _hcs[_k] = new DHistogram[new_leafs][ /*ncol*/]; for (int nl = tmax; nl < _tree.len(); nl++) _hcs[_k][nl - tmax] = _tree.undecided(nl)._hs; if (_did_split) _tree._depth++; }
// helper for debugging @SuppressWarnings("unused") protected static void printGenerateTrees(DTree[] trees) { for (DTree dtree : trees) if (dtree != null) { try { PrintWriter writer = new PrintWriter("/tmp/h2o-3.tree" + ++counter + ".txt", "UTF-8"); writer.println(dtree.root().toString2(new StringBuilder(), 0)); writer.close(); } catch (FileNotFoundException | UnsupportedEncodingException e) { e.printStackTrace(); } System.out.println(dtree.root().toString2(new StringBuilder(), 0)); } }