Search in sources :

Example 1 with QRDSolver

use of org.apache.ignite.ml.math.decompositions.QRDSolver in project ignite by apache.

the class LinearRegressionQRTrainer method train.

/**
 * {@inheritDoc}
 */
@Override
public LinearRegressionModel train(Matrix data) {
    Vector groundTruth = extractGroundTruth(data);
    Matrix inputs = extractInputs(data);
    QRDecomposition decomposition = new QRDecomposition(inputs);
    QRDSolver solver = new QRDSolver(decomposition.getQ(), decomposition.getR());
    Vector variables = solver.solve(groundTruth);
    Vector weights = variables.viewPart(1, variables.size() - 1);
    double intercept = variables.get(0);
    return new LinearRegressionModel(weights, intercept);
}
Also used : QRDecomposition(org.apache.ignite.ml.math.decompositions.QRDecomposition) Matrix(org.apache.ignite.ml.math.Matrix) QRDSolver(org.apache.ignite.ml.math.decompositions.QRDSolver) FunctionVector(org.apache.ignite.ml.math.impls.vector.FunctionVector) Vector(org.apache.ignite.ml.math.Vector)

Aggregations

Matrix (org.apache.ignite.ml.math.Matrix)1 Vector (org.apache.ignite.ml.math.Vector)1 QRDSolver (org.apache.ignite.ml.math.decompositions.QRDSolver)1 QRDecomposition (org.apache.ignite.ml.math.decompositions.QRDecomposition)1 FunctionVector (org.apache.ignite.ml.math.impls.vector.FunctionVector)1