Skip to content

Commit

Permalink
Write trees to individual files for easier debugging.
Browse files Browse the repository at this point in the history
  • Loading branch information
arnocandel committed Mar 17, 2015
1 parent 70b97a9 commit 9ba0e12
Showing 1 changed file with 16 additions and 2 deletions.
18 changes: 16 additions & 2 deletions src/main/java/hex/gbm/SharedTreeModelBuilder.java
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,9 @@
import water.util.ModelUtils;
import water.util.Utils;

import java.io.FileNotFoundException;
import java.io.PrintWriter;
import java.io.UnsupportedEncodingException;
import java.util.Arrays;
import java.util.Random;

Expand Down Expand Up @@ -938,11 +941,22 @@ public static Random createRNG(long seed) {
return new MersenneTwisterRNG(new int[] { (int)(seed>>32L),(int)seed });
}

static int counter = 0;
// helper for debugging
static protected void printGenerateTrees(DTree[] trees) {
for( int k=0; k<trees.length; k++ )
if( trees[k] != null )
System.out.println(trees[k].root().toString2(new StringBuilder(),0));
if( trees[k] != null ) {
try {
PrintWriter writer = new PrintWriter("/tmp/h2o.tree" + ++counter + ".txt", "UTF-8");
writer.println(trees[k].root().toString2(new StringBuilder(), 0));
writer.close();
} catch (FileNotFoundException e) {
e.printStackTrace();
} catch (UnsupportedEncodingException e) {
e.printStackTrace();
}
System.out.println(trees[k].root().toString2(new StringBuilder(), 0));
}
}

protected final void debugPrintTreeColumns(Frame fr) {
Expand Down

0 comments on commit 9ba0e12

Please sign in to comment.