// have to compute
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);
  }
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();
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();
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(),