Skip to content

Commit

Permalink
fix up the CSS on these pages
Browse files Browse the repository at this point in the history
  • Loading branch information
spennihana committed Mar 11, 2014
1 parent ef2e92d commit 8af9124
Show file tree
Hide file tree
Showing 5 changed files with 47 additions and 36 deletions.
12 changes: 8 additions & 4 deletions lib/resources/h2o/css/main.css
Original file line number Diff line number Diff line change
Expand Up @@ -50,12 +50,16 @@ body {
-webkit-font-smoothing: antialiased;
}

td {
td, th {
min-width: 115px;
}

/*.table th, .table td {*/
/*text-align: left;*/
/*}*/

span.btn_custom{
display: block;
width: 95px;
height: 100%;
margin: 0 auto;
}


30 changes: 15 additions & 15 deletions src/main/java/hex/gbm/DTree.java
Original file line number Diff line number Diff line change
Expand Up @@ -687,54 +687,54 @@ public void generateHTML(String title, StringBuilder sb) {
}

DocGen.HTML.arrayHead(sb);
sb.append("<tr class='warning'>");
sb.append("<th>Actual / Predicted</th>"); // Row header
sb.append("<tr class='warning' style='min-width:60px'>");
sb.append("<th style='min-width:60px'>Actual / Predicted</th>"); // Row header
for( int i=0; i<cm._arr.length; i++ )
sb.append("<th>").append(domain[i]).append("</th>");
sb.append("<th>Error</th>");
sb.append("<th style='min-width:60px'>").append(domain[i]).append("</th>");
sb.append("<th style='min-width:60px'>Error</th>");
sb.append("</tr>");

// Main CM Body
long tsum=0, terr=0; // Total observations & errors
for( int i=0; i<cm._arr.length; i++ ) { // Actual loop
sb.append("<tr>");
sb.append("<th>").append(domain[i]).append("</th>");// Row header
sb.append("<tr style='min-width:60px'>");
sb.append("<th style='min-width:60px'>").append(domain[i]).append("</th>");// Row header
long sum=0, err=0; // Per-class observations & errors
for( int j=0; j<cm._arr[i].length; j++ ) { // Predicted loop
sb.append(i==j ? "<td style='background-color:LightGreen'>":"<td>");
sb.append(i==j ? "<td style='background-color:LightGreen; min-width:60px;'>":"<td style='min-width:60px'>");
sb.append(cm._arr[i][j]).append("</td>");
sum += cm._arr[i][j]; // Per-class observations
if( i != j ) err += cm._arr[i][j]; // and errors
}
sb.append(String.format("<th>%5.3f = %d / %d</th>", (double)err/sum, err, sum));
sb.append(String.format("<th style='min-width:60px'>%5.3f = %d / %d</th>", (double)err/sum, err, sum));
tsum += sum; terr += err; // Bump totals
}
sb.append("</tr>");

// Last row of CM
sb.append("<tr>");
sb.append("<th>Totals</th>");// Row header
sb.append("<tr style='min-width:60px'>");
sb.append("<th style='min-width:60px'>Totals</th>");// Row header
for( int j=0; j<cm._arr.length; j++ ) { // Predicted loop
long sum=0;
for( int i=0; i<cm._arr.length; i++ ) sum += cm._arr[i][j];
sb.append("<td>").append(sum).append("</td>");
sb.append("<td style='min-width:60px'>").append(sum).append("</td>");
}
sb.append(String.format("<th>%5.3f = %d / %d</th>", (double)terr/tsum, terr, tsum));
sb.append(String.format("<th style='min-width:60px'>%5.3f = %d / %d</th>", (double)terr/tsum, terr, tsum));
sb.append("</tr>");
DocGen.HTML.arrayTail(sb);
}

if( errs != null ) {
DocGen.HTML.section(sb,"Mean Squared Error by Tree");
DocGen.HTML.arrayHead(sb);
sb.append("<tr><th>Trees</th>");
sb.append("<tr style='min-width:60px'><th>Trees</th>");
last = isClassifier() ? last : errs.length-1; // for regressor reports all errors
for( int i=last; i>=0; i-- )
sb.append("<td>").append(i).append("</td>");
sb.append("<td style='min-width:60px'>").append(i).append("</td>");
sb.append("</tr>");
sb.append("<tr><th class='warning'>MSE</th>");
for( int i=last; i>=0; i-- )
sb.append(!Double.isNaN(errs[i]) ? String.format("<td>%5.3f</td>",errs[i]) : "<td>---</td>");
sb.append(!Double.isNaN(errs[i]) ? String.format("<td style='min-width:60px'>%5.3f</td>",errs[i]) : "<td style='min-width:60px'>---</td>");
sb.append("</tr>");
DocGen.HTML.arrayTail(sb);
}
Expand Down
11 changes: 7 additions & 4 deletions src/main/java/water/api/Inspect.java
Original file line number Diff line number Diff line change
Expand Up @@ -483,15 +483,18 @@ public String build(Response response, JsonArray array, String contextName) {
// technically I should check if the whole domain is ints, I just check mu and sigma instead.
// enums have mu = sigma = NaN, unless they are just transformed int column.
if(!Double.isNaN(_va._cols[i]._mean) && !Double.isNaN(_va._cols[i]._sigma)){
String btn = "<a href='ToEnum.html?key=" + k + "&col_index=" + (i) + "&to_enum=false" + "'>"
+ "<button type='submit' class='btn btn-custom'>As Integer</button>";
String btn = "<span class='btn_custom'>\n";
btn += "<a href='ToEnum.html?key=" + k + "&col_index=" + (i) + "&to_enum=false" + "'>\n"
+ "<button type='submit' class='btn btn-custom'>As Integer</button>\n";
btn += "</span>\n";
row.addProperty(_va._cols[i]._name, btn);
} else row.addProperty(_va._cols[i]._name, "");
continue;
}

String btn = "<a href='ToEnum.html?key=" + k + "&col_index=" + (i) + "&to_enum=true" + "'>"
String btn = "<span class='btn_custom'>\n";
btn += "<a href='ToEnum.html?key=" + k + "&col_index=" + (i) + "&to_enum=true" + "'>"
+ "<button type='submit' class='btn btn-custom'>As Factor</button>";
btn += "</span>\n";
row.addProperty(_va._cols[i]._name, btn);
}
sb.append(ARRAY_HEADER_ROW_BUILDER.build(response, row, contextName));
Expand Down
12 changes: 8 additions & 4 deletions src/main/java/water/api/Inspect2.java
Original file line number Diff line number Diff line change
Expand Up @@ -142,14 +142,18 @@ public static Response redirect(Request req, String src_key) {
sb.append("<td>").append("Change Type").append("</td>");
for( int i=0; i<cols.length; i++ ) {
if(cols[i].type==ColType.Int) {
String btn = "<a href='ToEnum2.html?src_key=" + src_key._key.toString() + "&column_index=" + (i+1) + "'>"
+ "<button type='submit' class='btn btn-custom'>As Factor</button>";
String btn = "<span class='btn_custom'>\n";
btn += "<a href='ToEnum2.html?src_key=" + src_key._key.toString() + "&column_index=" + (i+1) + "'>"
+ "<button type='submit' class='btn btn-custom'>As Factor</button>\n";
btn += "</span>\n";
sb.append("<td><b>").append(btn).append("</b></td>");
continue;
}
if(src_key.vecs()[i] instanceof TransfVec) {
String btn2 = "<a href='ToInt2.html?src_key=" + src_key._key.toString() + "&column_index=" + (i+1) + "'>"
+ "<button type='submit' class='btn btn-custom'>As Integer</button>";
String btn2 = "<span class='btn_custom'>\n";
btn2 += "<a href='ToInt2.html?src_key=" + src_key._key.toString() + "&column_index=" + (i+1) + "'>"
+ "<button type='submit' class='btn btn-custom'>As Integer</button>\n";
btn2 += "</span>\n";
sb.append("<td><b>").append(btn2).append("</b></td>");
continue;
}
Expand Down
18 changes: 9 additions & 9 deletions src/main/java/water/util/Utils.java
Original file line number Diff line number Diff line change
Expand Up @@ -1127,11 +1127,11 @@ public static void printConfusionMatrix(StringBuilder sb, long[][] cm, String[]

// Header
if (html) {
sb.append("<tr class='warning'>");
sb.append("<tr class='warning' style='min-width:60px'>");
sb.append("<th>Actual / Predicted</th>");
for( int p=0; p<pdomain.length; p++ )
if( pdomain[p] != null )
sb.append("<th>").append(pdomain[p]).append("</th>");
sb.append("<th style='min-width:60px'>").append(pdomain[p]).append("</th>");
sb.append("<th>Error</th>");
sb.append("</tr>");
} else {
Expand All @@ -1156,8 +1156,8 @@ public static void printConfusionMatrix(StringBuilder sb, long[][] cm, String[]
for( int a=0; a<cm.length; a++ ) {
if( adomain[a] == null ) continue;
if (html) {
sb.append("<tr>");
sb.append("<th>").append(adomain[a]).append("</th>");
sb.append("<tr style='min-width:60px'>");
sb.append("<th style='min-width:60px'>").append(adomain[a]).append("</th>");
} else {
sb.append(String.format(fmtS,adomain[a]));
}
Expand All @@ -1168,30 +1168,30 @@ public static void printConfusionMatrix(StringBuilder sb, long[][] cm, String[]
if( onDiag ) correct = cm[a][p];
String id = "";
if (html) {
sb.append(onDiag ? "<td style='background-color:LightGreen' "+id+">":"<td "+id+">").append(String.format("%,d", cm[a][p])).append("</td>");
sb.append(onDiag ? "<td style='min-width: 60px; background-color:LightGreen' "+id+">":"<td style='min-width: 60px;'"+id+">").append(String.format("%,d", cm[a][p])).append("</td>");
} else {
sb.append(String.format(fmt,cm[a][p]));
}
}
long err = acts[a]-correct;
terr += err;
if (html) {
sb.append(String.format("<th>%5.3f = %,d / %,d</th></tr>", (double)err/acts[a], err, acts[a]));
sb.append(String.format("<th style='min-width: 60px;'>%5.3f = %,d / %,d</th></tr>", (double)err/acts[a], err, acts[a]));
} else {
sb.append(" " + String.format("%5.3f = %,d / %d\n", (double)err/acts[a], err, acts[a]));
}
}

// Last row of CM
if (html) {
sb.append("<tr><th>Totals</th>");
sb.append("<tr style='min-width:60px'><th>Totals</th>");
} else {
sb.append(String.format(fmtS, "Totals"));
}
for( int p=0; p<pdomain.length; p++ ) {
if( pdomain[p] == null ) continue;
if (html) {
sb.append("<td>").append(String.format("%,d", preds[p])).append("</td>");
sb.append("<td style='min-width:60px'>").append(String.format("%,d", preds[p])).append("</td>");
} else {
sb.append(String.format(fmt, preds[p]));
}
Expand All @@ -1200,7 +1200,7 @@ public static void printConfusionMatrix(StringBuilder sb, long[][] cm, String[]
for (long n : acts) nrows += n;

if (html) {
sb.append(String.format("<th>%5.3f = %,d / %,d</th></tr>", (float)terr/nrows, terr, nrows));
sb.append(String.format("<th style='min-width:60px'>%5.3f = %,d / %,d</th></tr>", (float)terr/nrows, terr, nrows));
DocGen.HTML.arrayTail(sb);
} else {
sb.append(" " + String.format("%5.3f = %,d / %,d\n", (float)terr/nrows, terr, nrows));
Expand Down

0 comments on commit 8af9124

Please sign in to comment.