org.ujmp.core.Matrix.getCoordinatesOfMaximum()方法的使用及代码示例

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

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

Matrix.getCoordinatesOfMaximum介绍

暂无

代码示例

代码示例来源:origin: jdmp/java-data-mining-package

public int getTargetClass() {
  return (int) getAsMatrix(TARGET).toRowVector(Ret.NEW).getCoordinatesOfMaximum()[ROW];
}

代码示例来源:origin: jdmp/java-data-mining-package

public int getRecognizedClass() {
  return (int) getAsMatrix(PREDICTED).toRowVector(Ret.NEW).getCoordinatesOfMaximum()[ROW];
}

代码示例来源:origin: jdmp/java-data-mining-package

} else {
  int targetClass = (int) s.getAsMatrix(getTargetLabel()).toRowVector(Ret.NEW)
      .getCoordinatesOfMaximum()[ROW];
  prob.y[i] = targetClass;

代码示例来源:origin: jdmp/java-data-mining-package

public void trainAll(ListDataSet dataSet) {
  MapMatrix<Long, Integer> count = new DefaultMapMatrix<Long, Integer>();
  for (Sample s : dataSet) {
    Matrix m = s.getAsMatrix(Variable.TARGET);
    long target = m.getCoordinatesOfMaximum()[COLUMN];
    maxClassId = Math.max(maxClassId, target);
    Integer c = count.get(target);
    if (c == null) {
      c = 0;
    }
    c++;
    count.put(target, c);
  }
  int max = 0;
  long pc = 0;
  for (Long t : count.keySet()) {
    Integer c = count.get(t);
    if (c > max) {
      max = c;
      pc = t;
    }
  }
  prediction = Matrix.Factory.zeros(1, maxClassId + 1);
  prediction.setAsDouble(1.0, 0, pc);
}

代码示例来源:origin: jdmp/java-data-mining-package

int targetClass = (int) s.getAsMatrix(getTargetLabel()).toColumnVector(Ret.LINK).getCoordinatesOfMaximum()[COLUMN];
prob.y[i] = targetClass;
long columnCount = input.getColumnCount();

代码示例来源:origin: ujmp/universal-java-matrix-package

@Test
public final void testGetCoordinatesOfMaximum() throws Exception {
  Matrix m = getTestMatrix();
  long[] c = m.getCoordinatesOfMaximum();
  assertTrue(getLabel(), Coordinates.equals(c, new long[] { 1, 1 }));
  m = createMatrixWithAnnotation(2, 2);
  m.setAsDouble(Double.NaN, 0, 0);
  m.setAsDouble(Double.NaN, 0, 1);
  m.setAsDouble(Double.NaN, 1, 0);
  m.setAsDouble(Double.NaN, 1, 1);
  c = m.getCoordinatesOfMaximum();
  assertTrue(getLabel(), Coordinates.equals(c, new long[] { -1, -1 }));
  if (m instanceof Erasable) {
    ((Erasable) m).erase();
  }
}

代码示例来源:origin: jdmp/java-data-mining-package

public SampleToInstanceWrapper(Matrix input, Matrix sampleWeight, Matrix targetOutput,
    boolean discrete, boolean includeTarget) {
  super((int) input.toRowVector(Ret.LINK).getRowCount() + 1);
  input = input.toRowVector(Ret.LINK);
  if (sampleWeight != null) {
    setWeight(sampleWeight.doubleValue());
  } else {
    setWeight(1.0);
  }
  for (int i = 0; i < input.getRowCount(); i++) {
    if (discrete) {
      setValue(i, (int) input.getAsDouble(i, 0));
    } else {
      setValue(i, input.getAsDouble(i, 0));
    }
  }
  if (includeTarget && targetOutput != null) {
    long[] c = targetOutput.toRowVector(Ret.NEW).getCoordinatesOfMaximum();
    setValue((int) input.getRowCount(), c[Matrix.ROW]);
  }
}

代码示例来源:origin: ujmp/universal-java-matrix-package

@Test
public final void testGetCoordinatesOfMininim() throws Exception {
  Matrix m = getTestMatrix();
  long[] c = m.getCoordinatesOfMinimum();
  assertTrue(getLabel(), Coordinates.equals(c, new long[] { 1, 2 }));
  m = createMatrixWithAnnotation(2, 2);
  m.setAsDouble(Double.NaN, 0, 0);
  m.setAsDouble(Double.NaN, 0, 1);
  m.setAsDouble(Double.NaN, 1, 0);
  m.setAsDouble(Double.NaN, 1, 1);
  c = m.getCoordinatesOfMaximum();
  assertTrue(getLabel(), Coordinates.equals(c, new long[] { -1, -1 }));
  if (m instanceof Erasable) {
    ((Erasable) m).erase();
  }
}

相关文章

Matrix类方法