use of org.apache.ignite.ml.math.Matrix in project ignite by apache.
the class AbstractMultipleLinearRegression method estimateRegressionParametersStandardErrors.
/**
* {@inheritDoc}
*/
@Override
public double[] estimateRegressionParametersStandardErrors() {
Matrix betaVariance = estimateRegressionParametersVariance();
double sigma = calculateErrorVariance();
int len = betaVariance.rowSize();
double[] res = new double[len];
for (int i = 0; i < len; i++) res[i] = Math.sqrt(sigma * betaVariance.getX(i, i));
return res;
}
use of org.apache.ignite.ml.math.Matrix in project ignite by apache.
the class AbstractVector method toMatrixPlusOne.
/** {@inheritDoc} */
@Override
public Matrix toMatrixPlusOne(boolean rowLike, double zeroVal) {
Matrix res = likeMatrix(rowLike ? 1 : size() + 1, rowLike ? size() + 1 : 1);
if (res == null)
return null;
res.set(0, 0, zeroVal);
if (rowLike)
new MatrixView(res, 0, 1, 1, size()).assignRow(0, this);
else
new MatrixView(res, 1, 0, size(), 1).assignColumn(0, this);
return res;
}
use of org.apache.ignite.ml.math.Matrix in project ignite by apache.
the class SingularValueDecomposition method getCovariance.
/**
* Gets [n × n] covariance matrix.
*
* @param minSingularVal Value below which singular values are ignored.
*/
Matrix getCovariance(double minSingularVal) {
Matrix j = like(arg, s.length, s.length);
Matrix vMat = like(arg, v.length, v.length).assign(v);
for (int i = 0; i < s.length; i++) j.set(i, i, s[i] >= minSingularVal ? 1 / (s[i] * s[i]) : 0.0);
return vMat.times(j).times(vMat.transpose());
}
use of org.apache.ignite.ml.math.Matrix in project ignite by apache.
the class SingularValueDecomposition method getU.
/**
* Gets the left singular vectors {@code U}.
*
* @return {@code U}
*/
public Matrix getU() {
if (transpositionNeeded)
return like(arg, v.length, v.length).assign(v);
else {
int numCols = Math.min(m + 1, n);
Matrix r = like(arg, m, numCols);
for (int i = 0; i < m; i++) for (int j = 0; j < numCols; j++) r.set(i, j, u[i][j]);
return r;
}
}
use of org.apache.ignite.ml.math.Matrix in project ignite by apache.
the class DenseLocalOffHeapMatrix method likeIdentity.
/** {@inheritDoc} */
@Override
protected Matrix likeIdentity() {
int n = rowSize();
Matrix res = like(n, n);
// IMPL NOTE as opposed to on-heap matrices this one isn't initialized with zeroes
for (int i = 0; i < n; i++) for (int j = 0; j < n; j++) res.setX(i, j, i == j ? 1.0 : 0.0);
return res;
}
Aggregations