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

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

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

Matrix.pinv介绍

暂无

代码示例

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

public Object call() {
  Matrix result = getMatrixObject().getMatrix().pinv();
  return result;
}

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

Matrix ytrain = y.deleteRows(Ret.NEW, missingRows);
Matrix xinv = xtrain.pinv();
Matrix b = xinv.mtimes(ytrain);
Matrix bias2 = DenseDoubleMatrix2D.Factory.ones(x.getRowCount(), 1);

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

private static Matrix replaceInColumn(Matrix original, Matrix firstGuess, long column) {
  Matrix x = firstGuess.deleteColumns(Ret.NEW, column);
  Matrix y = original.selectColumns(Ret.NEW, column);
  List<Long> missingRows = new ArrayList<Long>();
  for (long i = y.getRowCount(); --i >= 0;) {
    double v = y.getAsDouble(i, 0);
    if (MathUtil.isNaNOrInfinite(v)) {
      missingRows.add(i);
    }
  }
  if (missingRows.isEmpty()) {
    return y;
  }
  Matrix xdel = x.deleteRows(Ret.NEW, missingRows);
  DenseDoubleMatrix2D bias1 = DenseDoubleMatrix2D.Factory.ones(xdel.getRowCount(), 1);
  Matrix xtrain = Matrix.Factory.horCat(xdel, bias1);
  Matrix ytrain = y.deleteRows(Ret.NEW, missingRows);
  Matrix xinv = xtrain.pinv();
  Matrix b = xinv.mtimes(ytrain);
  DenseDoubleMatrix2D bias2 = DenseDoubleMatrix2D.Factory.ones(x.getRowCount(), 1);
  Matrix yPredicted = Matrix.Factory.horCat(x, bias2).mtimes(b);
  // set non-missing values back to original values
  for (int row = 0; row < y.getRowCount(); row++) {
    double v = y.getAsDouble(row, 0);
    if (!Double.isNaN(v)) {
      yPredicted.setAsDouble(v, row, 0);
    }
  }
  return yPredicted;
}

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

Matrix m3 = m1.pinv();
Matrix m4 = m1.ginv();
assertEquals(mclass.toString(), 0.0, ref2.minus(m2).getRMS(), TOLERANCE);

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

public void trainAll(ListDataSet dataSet) {
  featureCount = getFeatureCount(dataSet);
  classCount = getClassCount(dataSet);
  dimensions = featureCount + classCount;
  Matrix x = Matrix.Factory.zeros(dataSet.size(), dimensions);
  int i = 0;
  for (Sample s : dataSet) {
    Matrix input = s.getAsMatrix(getInputLabel()).toColumnVector(Ret.LINK);
    for (int c = 0; c < featureCount; c++) {
      x.setAsDouble(input.getAsDouble(0, c), i, c);
    }
    Matrix target = s.getAsMatrix(getTargetLabel()).toColumnVector(Ret.LINK);
    for (int c = 0; c < classCount; c++) {
      x.setAsDouble(target.getAsDouble(0, c), i, c + featureCount);
    }
    i++;
  }
  meanMatrix = x.mean(Ret.NEW, Matrix.ROW, true);
  covarianceMatrix = x.cov(Ret.NEW, true, true);
  try {
    inverse = covarianceMatrix.inv();
    factor = 1.0 / Math.sqrt(covarianceMatrix.det() * Math.pow(2.0 * Math.PI, dimensions));
  } catch (Exception e) {
    inverse = covarianceMatrix.pinv();
    factor = 1.0;
  }
}

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

if (sampleCount < featureCount) {
  parameters = x.pinv(numberOfPrincipalComponents).mtimes(y);
} else {
  final Matrix xt = x.transpose();
  parameters = xt.mtimes(x).pinv(numberOfPrincipalComponents).mtimes(xt).mtimes(y);
  parameters = x.pinv().mtimes(y);
} else {
  final Matrix xt = x.transpose();
  parameters = xt.mtimes(x).pinv().mtimes(xt).mtimes(y);

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

Matrix pseudoInverse = dense.pinv();
double determinant = dense.det();

代码示例来源:origin: org.ujmp/ujmp-examples

Matrix pseudoInverse = dense.pinv();
double determinant = dense.det();

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

m1.setAsDouble(1.0, 2, 2);
Matrix m2 = m1.pinv();

相关文章

Matrix类方法