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);
}
Aggregations