|
Cosan
1.0
Data Analytics Library
|
Go to the documentation of this file.
5 #ifndef COSAN_COSANLINEARREGRESSION_H
6 #define COSAN_COSANLINEARREGRESSION_H
19 template<Numeric NumericType>
49 virtual const std::string
GetName()
const override {
50 return "Linear Regression/ Ordinary Least Square";}
56 if (this->
MBias==
true){
57 X.conservativeResize(X.rows(), X.cols()+1);
60 this->
MBeta = (X.transpose()*X).ldlt().solve(X.transpose()*Y);
61 if (this->
MBias==
true){
76 if (this->
MBias==
true){
81 return (X*this->
MBeta(Eigen::seq(0,X.cols()-1),Eigen::all)).array()+this->
MBeta(X.cols(),0);
83 else{
return X*this->
MBeta;}
90 #endif //COSAN_COSANLINEARREGRESSION_H
CosanMatrix< NumericType > GetInput()
Get a copy of CosanMatrix<NumericType> X.
CosanMatrix< NumericType > GetTarget()
Get a copy of CosanMatrix<NumericType> Y.
Eigen::Matrix< NumericType, Eigen::Dynamic, Eigen::Dynamic > CosanMatrix
CosanMatrix< NumericType > MBeta
virtual EProblemType GetProblemType() override
void fit(T &&X, const CosanMatrix< NumericType > &Y)
CosanLinear Model. All linear model inherit this object.
virtual EModelType GetModelType() override
CosanLinearRegression(CosanData< NumericType > &CD, bool Bias)
CosanLinearRegression(CosanRawData< NumericType > &RD, bool Bias)
virtual const std::string GetName() const override
Get the name of the objects.
virtual CosanMatrix< NumericType > predict(const CosanMatrix< NumericType > &X) override
void removeColumn(Matrix &matrix, gsl::index colToRemove)
CosanLinearRegression(bool Bias)
CosanLinearRegression(T &&X, const CosanMatrix< NumericType > &Y, bool Bias)