5 #ifndef MACHINE_LEARNING_LEASTSQUARES_HPP     6 #define MACHINE_LEARNING_LEASTSQUARES_HPP    10 #include "../include/matrix/Matrix.hpp"    23   MatrixD X, 
y, coefs, residuals;
    28     X.addColumn(MatrixD::ones(X.nRows(), 1), 0);
    29     y = std::move(labels);
    33     return regressionType;
    37     this->regressionType = regressionType;
    49     if (regressionType == WEIGHTED) {
    50       MatrixD vars = X.transpose().var();
    51       W = vars.asDiagonal();
    53       W = MatrixD::identity(X.nRows());
    55     MatrixD Xt = X.transpose();
    56     MatrixD first_part = Xt * W * X;
    57     first_part = first_part.inverse();
    58     MatrixD second_part = Xt * W * y;
    59     coefs = first_part * second_part;
    61     residuals = y - (X * coefs);
    62     residuals = residuals.transpose() * residuals;
    66     m.addColumn(MatrixD::ones(1, X.nCols()), 0);
    67     return m.transpose() * coefs;
    79 #endif //MACHINE_LEARNING_LEASTSQUARES_HPP RegressionType regressionType
Ordinary and weighted Least squares algorithm. 
RegressionType getRegressionType() const
k-nearest neighbors algorithm, able to do regression and classification 
void setRegressionType(RegressionType regressionType)
LeastSquares(MatrixD data, MatrixD labels, RegressionType regType=REGULAR)
const MatrixD & getResiduals() const
const MatrixD & getCoefs() const
MatrixD predict(MatrixD m)