org.apache.mahout.math.Matrix.setColumnLabelBindings()方法的使用及代码示例

x33g5p2x  于2022-01-25 转载在 其他  
字(12.0k)|赞(0)|评价(0)|浏览(131)

本文整理了Java中org.apache.mahout.math.Matrix.setColumnLabelBindings()方法的一些代码示例,展示了Matrix.setColumnLabelBindings()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Matrix.setColumnLabelBindings()方法的具体详情如下:
包路径:org.apache.mahout.math.Matrix
类名称:Matrix
方法名:setColumnLabelBindings

Matrix.setColumnLabelBindings介绍

[英]Sets a map of column label bindings in the receiver
[中]设置接收器中列标签绑定的映射

代码示例

代码示例来源:origin: apache/mahout

readLabels(in, columnLabelBindings, rowLabelBindings);
if (!columnLabelBindings.isEmpty()) {
 matrix.setColumnLabelBindings(columnLabelBindings);

代码示例来源:origin: apache/mahout

@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);
}

代码示例来源:origin: apache/mahout

@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);
}

代码示例来源:origin: apache/mahout

@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);
}

代码示例来源:origin: apache/mahout

@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());
}

代码示例来源:origin: apache/mahout

@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());
 }
}

代码示例来源:origin: apache/mahout

@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);
}

代码示例来源:origin: apache/mahout

@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);
}

代码示例来源:origin: org.apache.mahout/mahout-mr

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;
}

代码示例来源:origin: org.apache.mahout/mahout-core

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;
}

代码示例来源:origin: org.apache.mahout/mahout-mrlegacy

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;
}

代码示例来源:origin: org.apache.mahout/mahout-core

readLabels(in, columnLabelBindings, rowLabelBindings);
if (!columnLabelBindings.isEmpty()) {
 r.setColumnLabelBindings(columnLabelBindings);

代码示例来源:origin: org.apache.mahout/mahout-mrlegacy

readLabels(in, columnLabelBindings, rowLabelBindings);
if (!columnLabelBindings.isEmpty()) {
 matrix.setColumnLabelBindings(columnLabelBindings);

代码示例来源:origin: org.apache.mahout/mahout-mrlegacy

@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);
}

代码示例来源:origin: org.apache.mahout/mahout-mrlegacy

@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);
}

代码示例来源:origin: org.apache.mahout/mahout-mrlegacy

@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);
}

代码示例来源:origin: cloudera/mahout

@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());
}

代码示例来源:origin: cloudera/mahout

@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());
 }
}

代码示例来源:origin: cloudera/mahout

@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);
}

代码示例来源:origin: cloudera/mahout

@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);
}

相关文章