Search in sources :

Example 6 with RString

use of water.util.RString in project h2o-2 by h2oai.

the class CoxPHSurvfit method link.

public static String link(Key k, double x_new, String content) {
    RString rs = new RString("<a href='CoxPHSurvfit.query?model=%$key&x_new=%x_new'>%content</a>");
    rs.replace("key", k.toString());
    rs.replace("x_new", x_new);
    rs.replace("content", content);
    return rs.toString();
}
Also used : RString(water.util.RString)

Example 7 with RString

use of water.util.RString in project h2o-2 by h2oai.

the class GLM2 method link.

/** Return the query link to this page */
public static String link(Key k, String content) {
    RString rs = new RString("<a href='GLM2.query?source=%$key'>%content</a>");
    rs.replace("key", k.toString());
    rs.replace("content", content);
    return rs.toString();
}
Also used : RString(water.util.RString)

Example 8 with RString

use of water.util.RString in project h2o-2 by h2oai.

the class GLMModelView method coefs2html.

private void coefs2html(final Submodel sm, StringBuilder sb) {
    StringBuilder names = new StringBuilder();
    StringBuilder equation = new StringBuilder();
    StringBuilder vals = new StringBuilder();
    StringBuilder normVals = sm.norm_beta == null ? null : new StringBuilder();
    int[] sortedIds = new int[sm.beta.length];
    for (int i = 0; i < sortedIds.length; ++i) sortedIds[i] = i;
    final double[] b = sm.norm_beta == null ? sm.beta : sm.norm_beta;
    // now sort the indeces according to their abs value from biggest to smallest (but keep intercept last)
    int r = sortedIds.length - 1;
    for (int i = 1; i < r; ++i) {
        for (int j = 1; j < r - i; ++j) {
            if (Math.abs(b[sortedIds[j - 1]]) < Math.abs(b[sortedIds[j]])) {
                int jj = sortedIds[j];
                sortedIds[j] = sortedIds[j - 1];
                sortedIds[j - 1] = jj;
            }
        }
    }
    String[] cNames = glm_model.coefficients_names;
    boolean first = true;
    int j = 0;
    for (int i : sortedIds) {
        names.append("<th>" + cNames[sm.idxs[i]] + "</th>");
        vals.append("<td>" + sm.beta[i] + "</td>");
        if (first) {
            equation.append(DFORMAT.format(sm.beta[i]));
            first = false;
        } else {
            equation.append(sm.beta[i] > 0 ? " + " : " - ");
            equation.append(DFORMAT.format(Math.abs(sm.beta[i])));
        }
        if (i < (cNames.length - 1))
            equation.append("*x[" + cNames[i] + "]");
        if (sm.norm_beta != null)
            normVals.append("<td>" + sm.norm_beta[i] + "</td>");
        ++j;
    }
    sb.append("<h4>Equation</h4>");
    RString eq = null;
    switch(glm_model.glm.link) {
        case identity:
            eq = new RString("y = %equation");
            break;
        case logit:
            eq = new RString("y = 1/(1 + Math.exp(-(%equation)))");
            break;
        case log:
            eq = new RString("y = Math.exp((%equation)))");
            break;
        case inverse:
            eq = new RString("y = 1/(%equation)");
            break;
        case tweedie:
            eq = new RString("y = (%equation)^(1 -  )");
            break;
        default:
            eq = new RString("equation display not implemented");
            break;
    }
    eq.replace("equation", equation.toString());
    sb.append("<div style='width:100%;overflow:scroll;'>");
    sb.append("<div><code>" + eq + "</code></div>");
    sb.append("<h4>Coefficients</h4><table class='table table-bordered table-condensed'>");
    sb.append("<tr>" + names.toString() + "</tr>");
    sb.append("<tr>" + vals.toString() + "</tr>");
    sb.append("</table>");
    if (sm.norm_beta != null) {
        sb.append("<h4>Normalized Coefficients</h4>" + "<table class='table table-bordered table-condensed'>");
        sb.append("<tr>" + names.toString() + "</tr>");
        sb.append("<tr>" + normVals.toString() + "</tr>");
        sb.append("</table>");
    }
    sb.append("</div>");
}
Also used : RString(water.util.RString) RString(water.util.RString)

Example 9 with RString

use of water.util.RString in project h2o-2 by h2oai.

the class CreateFrame method toHTML.

@Override
public boolean toHTML(StringBuilder sb) {
    Frame fr = UKV.get(Key.make(key));
    if (fr == null) {
        return false;
    }
    RString aft = new RString("<a href='Inspect2.html?src_key=%$key'>%key</a>");
    aft.replace("key", key);
    DocGen.HTML.section(sb, "Frame creation done.<br/>Frame '" + aft.toString() + "' now has " + fr.numRows() + " rows and " + (fr.numCols() - 1) + " data columns, as well as a " + (response_factors == 1 ? "real-valued" : (response_factors == 2 ? "binomial" : "multi-nomial")) + " response variable as the first column.<br/>Number of chunks: " + fr.anyVec().nChunks() + ".");
    DocGen.HTML.paragraph(sb, FrameUtils.chunkSummary((Frame) UKV.get(Key.make(key))).toString().replace("\n", "<br/>"));
    return true;
}
Also used : RString(water.util.RString)

Example 10 with RString

use of water.util.RString in project h2o-2 by h2oai.

the class InsertMissingValues method toHTML.

@Override
public boolean toHTML(StringBuilder sb) {
    Frame fr = UKV.get(key);
    if (fr == null) {
        return false;
    }
    RString aft = new RString("<a href='Inspect2.html?src_key=%$key'>%key</a>");
    aft.replace("key", key);
    DocGen.HTML.section(sb, "Inserted missing values into frame '" + aft.toString() + " done.");
    return true;
}
Also used : Frame(water.fvec.Frame) RString(water.util.RString)

Aggregations

RString (water.util.RString)30 Frame (water.fvec.Frame)3 Test (org.junit.Test)2 AutoBuffer (water.AutoBuffer)1 PrettyPrint (water.PrettyPrint)1