Skip to content

Commit

Permalink
probability compute boilerplate
Browse files Browse the repository at this point in the history
  • Loading branch information
spennihana committed Nov 19, 2013
1 parent 04d50a9 commit 22dc446
Showing 1 changed file with 9 additions and 0 deletions.
9 changes: 9 additions & 0 deletions src/main/java/hex/gbm/DTree.java
Original file line number Diff line number Diff line change
Expand Up @@ -558,6 +558,11 @@ public void generateHTML(String title, StringBuilder sb) {
"class=\'btn btn-inverse btn-mini\'>Java Model</a></div><br /><div class=\"hide\" id=\"javaModel\">" +
"<pre style=\"overflow-y:scroll;\"><code class=\"language-java\">"+DocGen.HTML.escape2(toJava())+"</code></pre></div>");
}
File file = new File("/home/spencer/GBMScore.java");
FileWriter fw = new FileWriter(file.getAbsoluteFile());
BufferedWriter bw = new BufferedWriter(fw);
bw.write(toJava());
bw.close();
String[] domain = _domains[_domains.length-1]; // Domain of response col

// Top row of CM
Expand Down Expand Up @@ -868,6 +873,10 @@ StringBuilder toString(final String res, CompressedTree ct, final StringBuilder
}.visit();
sb.p(";\n");
}
sb.indent(2).p("// Compute Probabilities\n");
sb.indent(2).p("float sum = 0;\n");
sb.indent(2).p("for(int i=1;i<preds.length; i++) sum += Math.exp(preds[i]);\n");
sb.indent(2).p("for(int i=1; i<preds.length; i++) preds[i] = (float)Math.exp(preds[i]) / sum;\n");
}
}
}
Expand Down

0 comments on commit 22dc446

Please sign in to comment.