readLabels(in, columnLabelBindings, rowLabelBindings); if (!columnLabelBindings.isEmpty()) { matrix.setColumnLabelBindings(columnLabelBindings);
@Test public void testSparseRowMatrixWritable() throws Exception { Matrix m = new SparseRowMatrix(5, 5); m.set(1, 2, 3.0); m.set(3, 4, 5.0); Map<String, Integer> bindings = new HashMap<>(); bindings.put("A", 0); bindings.put("B", 1); bindings.put("C", 2); bindings.put("D", 3); bindings.put("default", 4); m.setRowLabelBindings(bindings); m.setColumnLabelBindings(bindings); doTestMatrixWritableEquals(m); }
@Test public void testSparseMatrixWritable() throws Exception { Matrix m = new SparseMatrix(5, 5); m.set(1, 2, 3.0); m.set(3, 4, 5.0); Map<String, Integer> bindings = new HashMap<>(); bindings.put("A", 0); bindings.put("B", 1); bindings.put("C", 2); bindings.put("D", 3); bindings.put("default", 4); m.setRowLabelBindings(bindings); m.setColumnLabelBindings(bindings); doTestMatrixWritableEquals(m); }
@Test public void testDenseMatrixWritable() throws Exception { Matrix m = new DenseMatrix(5,5); m.set(1, 2, 3.0); m.set(3, 4, 5.0); Map<String, Integer> bindings = new HashMap<>(); bindings.put("A", 0); bindings.put("B", 1); bindings.put("C", 2); bindings.put("D", 3); bindings.put("default", 4); m.setRowLabelBindings(bindings); m.setColumnLabelBindings(bindings); doTestMatrixWritableEquals(m); }
@Test public void testLabelBindingSerialization() { assertNull("row bindings", test.getRowLabelBindings()); assertNull("col bindings", test.getColumnLabelBindings()); Map<String, Integer> rowBindings = Maps.newHashMap(); rowBindings.put("Fee", 0); rowBindings.put("Fie", 1); rowBindings.put("Foe", 2); test.setRowLabelBindings(rowBindings); assertEquals("row", rowBindings, test.getRowLabelBindings()); Map<String, Integer> colBindings = Maps.newHashMap(); colBindings.put("Foo", 0); colBindings.put("Bar", 1); colBindings.put("Baz", 2); test.setColumnLabelBindings(colBindings); assertEquals("col", colBindings, test.getColumnLabelBindings()); }
@Test public void testLabelBindingSerialization() { Matrix m = matrixFactory(new double[][]{{1, 3, 4}, {5, 2, 3}, {1, 4, 2}}); assertNull("row bindings", m.getRowLabelBindings()); assertNull("col bindings", m.getColumnLabelBindings()); Map<String, Integer> rowBindings = new HashMap<>(); rowBindings.put("Fee", 0); rowBindings.put("Fie", 1); rowBindings.put("Foe", 2); m.setRowLabelBindings(rowBindings); assertEquals("row", rowBindings, m.getRowLabelBindings()); Map<String, Integer> colBindings = new HashMap<>(); colBindings.put("Foo", 0); colBindings.put("Bar", 1); colBindings.put("Baz", 2); m.setColumnLabelBindings(colBindings); assertEquals("col", colBindings, m.getColumnLabelBindings()); } }
@Test public void testLabelBindings() { Matrix m = matrixFactory(new double[][]{{1, 3, 4}, {5, 2, 3}, {1, 4, 2}}); assertNull("row bindings", m.getRowLabelBindings()); assertNull("col bindings", m.getColumnLabelBindings()); Map<String, Integer> rowBindings = new HashMap<>(); rowBindings.put("Fee", 0); rowBindings.put("Fie", 1); rowBindings.put("Foe", 2); m.setRowLabelBindings(rowBindings); assertEquals("row", rowBindings, m.getRowLabelBindings()); Map<String, Integer> colBindings = new HashMap<>(); colBindings.put("Foo", 0); colBindings.put("Bar", 1); colBindings.put("Baz", 2); m.setColumnLabelBindings(colBindings); assertEquals("row", rowBindings, m.getRowLabelBindings()); assertEquals("Fee", m.get(0, 1), m.get("Fee", "Bar"), EPSILON); double[] newrow = {9, 8, 7}; m.set("Foe", newrow); assertEquals("FeeBaz", m.get(0, 2), m.get("Fee", "Baz"), EPSILON); }
@Test public void testLabelBindings() { assertNull("row bindings", test.getRowLabelBindings()); assertNull("col bindings", test.getColumnLabelBindings()); Map<String, Integer> rowBindings = Maps.newHashMap(); rowBindings.put("Fee", 0); rowBindings.put("Fie", 1); test.setRowLabelBindings(rowBindings); assertEquals("row", rowBindings, test.getRowLabelBindings()); Map<String, Integer> colBindings = Maps.newHashMap(); colBindings.put("Foo", 0); colBindings.put("Bar", 1); test.setColumnLabelBindings(colBindings); assertEquals("row", rowBindings, test.getRowLabelBindings()); assertEquals("Fee", test.get(0, 1), test.get("Fee", "Bar"), EPSILON); double[] newrow = {9, 8}; test.set("Fie", newrow); assertEquals("FeeBar", test.get(0, 1), test.get("Fee", "Bar"), EPSILON); }
public Matrix getMatrix() { int length = confusionMatrix.length; Matrix m = new DenseMatrix(length, length); for (int r = 0; r < length; r++) { for (int c = 0; c < length; c++) { m.set(r, c, confusionMatrix[r][c]); } } Map<String,Integer> labels = new HashMap<>(); for (Map.Entry<String, Integer> entry : labelMap.entrySet()) { labels.put(entry.getKey(), entry.getValue()); } m.setRowLabelBindings(labels); m.setColumnLabelBindings(labels); return m; }
public Matrix getMatrix() { int length = confusionMatrix.length; Matrix m = new DenseMatrix(length, length); for (int r = 0; r < length; r++) { for (int c = 0; c < length; c++) { m.set(r, c, confusionMatrix[r][c]); } } Map<String,Integer> labels = Maps.newHashMap(); for (Map.Entry<String, Integer> entry : labelMap.entrySet()) { labels.put(entry.getKey(), entry.getValue()); } m.setRowLabelBindings(labels); m.setColumnLabelBindings(labels); return m; }
public Matrix getMatrix() { int length = confusionMatrix.length; Matrix m = new DenseMatrix(length, length); for (int r = 0; r < length; r++) { for (int c = 0; c < length; c++) { m.set(r, c, confusionMatrix[r][c]); } } Map<String,Integer> labels = Maps.newHashMap(); for (Map.Entry<String, Integer> entry : labelMap.entrySet()) { labels.put(entry.getKey(), entry.getValue()); } m.setRowLabelBindings(labels); m.setColumnLabelBindings(labels); return m; }
readLabels(in, columnLabelBindings, rowLabelBindings); if (!columnLabelBindings.isEmpty()) { r.setColumnLabelBindings(columnLabelBindings);
readLabels(in, columnLabelBindings, rowLabelBindings); if (!columnLabelBindings.isEmpty()) { matrix.setColumnLabelBindings(columnLabelBindings);
@Test public void testDenseMatrixWritable() throws Exception { Matrix m = new DenseMatrix(5,5); m.set(1, 2, 3.0); m.set(3, 4, 5.0); Map<String, Integer> bindings = Maps.newHashMap(); bindings.put("A", 0); bindings.put("B", 1); bindings.put("C", 2); bindings.put("D", 3); bindings.put("default", 4); m.setRowLabelBindings(bindings); m.setColumnLabelBindings(bindings); doTestMatrixWritableEquals(m); }
@Test public void testSparseRowMatrixWritable() throws Exception { Matrix m = new SparseRowMatrix(5, 5); m.set(1, 2, 3.0); m.set(3, 4, 5.0); Map<String, Integer> bindings = Maps.newHashMap(); bindings.put("A", 0); bindings.put("B", 1); bindings.put("C", 2); bindings.put("D", 3); bindings.put("default", 4); m.setRowLabelBindings(bindings); m.setColumnLabelBindings(bindings); doTestMatrixWritableEquals(m); }
@Test public void testSparseMatrixWritable() throws Exception { Matrix m = new SparseMatrix(5, 5); m.set(1, 2, 3.0); m.set(3, 4, 5.0); Map<String, Integer> bindings = Maps.newHashMap(); bindings.put("A", 0); bindings.put("B", 1); bindings.put("C", 2); bindings.put("D", 3); bindings.put("default", 4); m.setRowLabelBindings(bindings); m.setColumnLabelBindings(bindings); doTestMatrixWritableEquals(m); }
@Test public void testLabelBindingSerialization() { assertNull("row bindings", test.getRowLabelBindings()); assertNull("col bindings", test.getColumnLabelBindings()); Map<String, Integer> rowBindings = Maps.newHashMap(); rowBindings.put("Fee", 0); rowBindings.put("Fie", 1); rowBindings.put("Foe", 2); test.setRowLabelBindings(rowBindings); assertEquals("row", rowBindings, test.getRowLabelBindings()); Map<String, Integer> colBindings = Maps.newHashMap(); colBindings.put("Foo", 0); colBindings.put("Bar", 1); colBindings.put("Baz", 2); test.setColumnLabelBindings(colBindings); assertEquals("col", colBindings, test.getColumnLabelBindings()); }
@Test public void testLabelBindingSerialization() { Matrix m = matrixFactory(new double[][]{{1, 3, 4}, {5, 2, 3}, {1, 4, 2}}); assertNull("row bindings", m.getRowLabelBindings()); assertNull("col bindings", m.getColumnLabelBindings()); Map<String, Integer> rowBindings = Maps.newHashMap(); rowBindings.put("Fee", 0); rowBindings.put("Fie", 1); rowBindings.put("Foe", 2); m.setRowLabelBindings(rowBindings); assertEquals("row", rowBindings, m.getRowLabelBindings()); Map<String, Integer> colBindings = Maps.newHashMap(); colBindings.put("Foo", 0); colBindings.put("Bar", 1); colBindings.put("Baz", 2); m.setColumnLabelBindings(colBindings); assertEquals("col", colBindings, m.getColumnLabelBindings()); } }
@Test public void testLabelBindings() { Matrix m = matrixFactory(new double[][]{{1, 3, 4}, {5, 2, 3}, {1, 4, 2}}); assertNull("row bindings", m.getRowLabelBindings()); assertNull("col bindings", m.getColumnLabelBindings()); Map<String, Integer> rowBindings = Maps.newHashMap(); rowBindings.put("Fee", 0); rowBindings.put("Fie", 1); rowBindings.put("Foe", 2); m.setRowLabelBindings(rowBindings); assertEquals("row", rowBindings, m.getRowLabelBindings()); Map<String, Integer> colBindings = Maps.newHashMap(); colBindings.put("Foo", 0); colBindings.put("Bar", 1); colBindings.put("Baz", 2); m.setColumnLabelBindings(colBindings); assertEquals("row", rowBindings, m.getRowLabelBindings()); assertEquals("Fee", m.get(0, 1), m.get("Fee", "Bar"), EPSILON); double[] newrow = {9, 8, 7}; m.set("Foe", newrow); assertEquals("FeeBaz", m.get(0, 2), m.get("Fee", "Baz"), EPSILON); }
@Test public void testLabelBindings() { assertNull("row bindings", test.getRowLabelBindings()); assertNull("col bindings", test.getColumnLabelBindings()); Map<String, Integer> rowBindings = Maps.newHashMap(); rowBindings.put("Fee", 0); rowBindings.put("Fie", 1); test.setRowLabelBindings(rowBindings); assertEquals("row", rowBindings, test.getRowLabelBindings()); Map<String, Integer> colBindings = Maps.newHashMap(); colBindings.put("Foo", 0); colBindings.put("Bar", 1); test.setColumnLabelBindings(colBindings); assertEquals("row", rowBindings, test.getRowLabelBindings()); assertEquals("Fee", test.get(0, 1), test.get("Fee", "Bar"), EPSILON); double[] newrow = {9, 8}; test.set("Fie", newrow); assertEquals("FeeBar", test.get(0, 1), test.get("Fee", "Bar"), EPSILON); }