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

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

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

Matrix.euklideanDistanceTo介绍

暂无

代码示例

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

public Matrix predictOne(Matrix input) {
    List<Sortable<Double, Matrix>> bestResults = new FastArrayList<Sortable<Double, Matrix>>();
    for (Sample s : dataSet) {
      Matrix reference = s.getAsMatrix(getInputLabel());
      double distance = input.euklideanDistanceTo(reference, true);
      if (bestResults.size() < k) {
        bestResults.add(new Sortable<Double, Matrix>(distance, s
            .getAsMatrix(getTargetLabel())));
        Collections.sort(bestResults);
      } else if (distance < bestResults.get(k - 1).getComparable()) {
        bestResults.remove(k - 1);
        bestResults.add(new Sortable<Double, Matrix>(distance, s
            .getAsMatrix(getTargetLabel())));
        Collections.sort(bestResults);
      }
    }
    List<Matrix> results = new FastArrayList<Matrix>();
    for (Sortable<Double, Matrix> s : bestResults) {
      results.add(s.getObject().toColumnVector(Ret.LINK));
    }
    Matrix resultMatrix = Matrix.Factory.vertCat(results);
    Matrix mean = resultMatrix.mean(Ret.NEW, Matrix.ROW, true);
    return mean;
  }
}

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

weightVectors[row][col] = m;
double distance = input.euklideanDistanceTo(m, true);
distanceMatrix.setAsDouble(distance, row, col);
if (distance < bestDistance) {

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

d = newBestGuess.euklideanDistanceTo(bestGuess, true) / missingCount;
System.out.println("delta: " + d);
System.out.println("============================================");

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

private Matrix getDistanceMatrix() {
  Matrix distanceMatrix = Matrix.Factory.zeros(getSource().getRowCount(), getSource()
      .getRowCount());
  for (int r = 0; r < getSource().getRowCount(); r++) {
    for (int c = 0; c < getSource().getRowCount(); c++) {
      if (r != c) {
        Matrix m1 = getSource().selectRows(Ret.LINK, r);
        Matrix m2 = getSource().selectRows(Ret.LINK, c);
        double dist = m1.euklideanDistanceTo(m2, true);
        distanceMatrix.setAsDouble(dist, r, c);
      }
    }
  }
  return distanceMatrix;
}

相关文章

Matrix类方法