/** * Annotate the number of columns and rows of the training data set in the job parameter JSON * * @return JsonObject annotated with num_cols and num_rows of the training data set */ @Override public JsonObject toJSON() { JsonObject jo = super.toJSON(); if (source != null) { jo.getAsJsonObject("source").addProperty("num_cols", source.numCols()); jo.getAsJsonObject("source").addProperty("num_rows", source.numRows()); } return jo; }
/** * Annotate the number of columns and rows of the validation data set in the job parameter JSON * * @return JsonObject annotated with num_cols and num_rows of the validation data set */ @Override public JsonObject toJSON() { JsonObject jo = super.toJSON(); if (validation != null) { jo.getAsJsonObject("validation").addProperty("num_cols", validation.numCols()); jo.getAsJsonObject("validation").addProperty("num_rows", validation.numRows()); } return jo; }
/** * Annotate the name of the response column in the job parameter JSON * * @return JsonObject annotated with the name of the response column */ @Override public JsonObject toJSON() { JsonObject jo = super.toJSON(); if (source != null) { int idx = source.find(response); if (idx == -1) { Vec vm = response.masterVec(); if (vm != null) idx = source.find(vm); } jo.getAsJsonObject("response") .add("name", new JsonPrimitive(idx == -1 ? "null" : source._names[idx])); } return jo; }
/** * Annotate the used and ignored columns in the job parameter JSON For both the used and the * ignored columns, the following rules apply: If the number of columns is less or equal than * 100, a dense list of used columns is reported. If the number of columns is greater than 100, * the number of columns is reported. If the number of columns is 0, a "N/A" is reported. * * @return JsonObject annotated with used/ignored columns */ @Override public JsonObject toJSON() { JsonObject jo = super.toJSON(); if (!jo.has("source") || source == null) return jo; HashMap<String, int[]> map = new HashMap<String, int[]>(); map.put("used_cols", cols); map.put("ignored_cols", ignored_cols); for (String key : map.keySet()) { int[] val = map.get(key); if (val != null) { if (val.length > 100) jo.getAsJsonObject("source").addProperty("num_" + key, val.length); else if (val.length > 0) { StringBuilder sb = new StringBuilder(); for (int c : val) sb.append(c + ","); jo.getAsJsonObject("source") .addProperty(key, sb.toString().substring(0, sb.length() - 1)); } else { jo.getAsJsonObject("source").add(key, JsonNull.INSTANCE); } } } return jo; }