public Map<String, Object> calculateObjects(Map<String, Object> input) { Map<String, Object> result = new HashMap<String, Object>(); Matrix source = MathUtil.getMatrix(input.get(SOURCE)); Matrix target = Matrix.Factory.zeros(source.getRowCount(), 1); long cols = source.getColumnCount(); long rows = source.getRowCount(); for (int k = 0; k < rows; k++) { int tp = 0; int fn = 0; for (int r = 0; r < rows; r++) { for (int c = 0; c < cols; c++) { int count = source.getAsInt(r, c); boolean expected = r == k; boolean predicted = c == k; if (expected && predicted) { tp += count; } else if (expected && (!predicted)) { fn += count; } } } target.setAsDouble(MathUtil.sensitivity(tp, fn), k, 0); } result.put(TARGET, target); return result; }