protected static Response scoreOne(Frame frame, Model score_model) {
    water.ModelMetrics metrics = water.ModelMetrics.getFromDKV(score_model, frame);
    if (null == metrics) {
      // have to compute
      water.util.Log.debug("Cache miss: computing ModelMetrics. . .");
      long before = System.currentTimeMillis();
      Frame predictions = score_model.score(frame, true); // TODO: for now we're always calling adapt inside score
      long after = System.currentTimeMillis();
      ConfusionMatrix cm = new ConfusionMatrix(); // for regression this computes the MSE
      AUC auc = null;
      HitRatio hr = null;
      if (score_model.isClassifier()) {
        auc = new AUC();
//      hr = new HitRatio();
        score_model.calcError(frame, frame.vec(score_model.responseName()), predictions, predictions, "Prediction error:",
                                      true, 20, cm, auc, hr);
      } else {
        score_model.calcError(frame, frame.vec(score_model.responseName()), predictions, predictions, "Prediction error:",
                                      true, 20, cm, null, null);
      }
      // Now call AUC and ConfusionMatrix and maybe HitRatio
      metrics = new water.ModelMetrics(score_model.getUniqueId(),
                                       score_model.getModelCategory(),
                                       frame.getUniqueId(),
                                       after - before,
                                       after,
                                       auc,
                                       cm);
      // Put the metrics into the KV store
      metrics.putInDKV();
    } else {
      // it's already cached in the DKV
      water.util.Log.debug("using ModelMetrics from the cache. . .");
    }
    JsonObject metricsJson = metrics.toJSON();
    JsonArray metricsArray = new JsonArray();
    metricsArray.add(metricsJson);
    JsonObject result = new JsonObject();
    result.add("metrics", metricsArray);
    return Response.done(result);
  }
protected static Response scoreOne(Frame frame, Model score_model) {
    water.ModelMetrics metrics = water.ModelMetrics.getFromDKV(score_model, frame);
    if (null == metrics) {
     
      water.util.Log.debug("Cache miss: computing ModelMetrics. . .");
      long before = System.currentTimeMillis();
      Frame predictions = score_model.score(frame, true);
      long after = System.currentTimeMillis();
      ConfusionMatrix cm = new ConfusionMatrix();
      AUC auc = null;
      HitRatio hr = null;
      if (score_model.isClassifier()) {
        auc = new AUC();
        score_model.calcError(frame, frame.vec(score_model.responseName()), predictions, predictions, "Prediction error:",
                                      true, 20, cm, auc, hr);
      } else {
        score_model.calcError(frame, frame.vec(score_model.responseName()), predictions, predictions, "Prediction error:",
                                      true, 20, cm, null, null);
      }
     
      metrics = new water.ModelMetrics(score_model.getUniqueId(),
                                       score_model.getModelCategory(),
                                       frame.getUniqueId(),
                                       after - before,
                                       after,
                                       auc,
                                       cm);
     
      metrics.putInDKV();
    } else {
     
      water.util.Log.debug("using ModelMetrics from the cache. . .");
    }
    JsonObject metricsJson = metrics.toJSON();
    JsonArray metricsArray = new JsonArray();
    metricsArray.add(metricsJson);
    JsonObject result = new JsonObject();
    result.add("metrics", metricsArray);
    return Response.done(result);
  }
protected static response scoreone(frame frame, model score_model) { water.modelmetrics metrics = water.modelmetrics.getfromdkv(score_model, frame); if (null == metrics) { water.util.log.debug("cache miss: computing modelmetrics. . ."); long before = system.currenttimemillis(); frame predictions = score_model.score(frame, true); long after = system.currenttimemillis(); confusionmatrix cm = new confusionmatrix(); auc auc = null; hitratio hr = null; if (score_model.isclassifier()) { auc = new auc(); score_model.calcerror(frame, frame.vec(score_model.responsename()), predictions, predictions, "prediction error:", true, 20, cm, auc, hr); } else { score_model.calcerror(frame, frame.vec(score_model.responsename()), predictions, predictions, "prediction error:", true, 20, cm, null, null); } metrics = new water.modelmetrics(score_model.getuniqueid(), score_model.getmodelcategory(), frame.getuniqueid(), after - before, after, auc, cm); metrics.putindkv(); } else { water.util.log.debug("using modelmetrics from the cache. . ."); } jsonobject metricsjson = metrics.tojson(); jsonarray metricsarray = new jsonarray(); metricsarray.add(metricsjson); jsonobject result = new jsonobject(); result.add("metrics", metricsarray); return response.done(result); }