33 #ifndef GRT_LINEAR_LEAST_SQUARES_HEADER 34 #define GRT_LINEAR_LEAST_SQUARES_HEADER 36 #include "../../CoreModules/MLBase.h" 75 warningLog << __GRT_LOG__ <<
" Failed to compute solution, input vectors are empty!" << std::endl;
80 warningLog << __GRT_LOG__ <<
" Failed to compute solution, input vectors do not have the same size!" << std::endl;
84 const unsigned int N = x.
getSize();
96 for(
unsigned int i=0; i<N; i++){
104 denom = (N * sumx2 - SQR(sumx));
107 warningLog << __GRT_LOG__ <<
" Failed to compute solution, singular matrix detected!" << std::endl;
111 m = (N*sumxy - sumx*sumy) / denom;
112 b = (sumy*sumx2 - sumx*sumxy) / denom;
121 r = (sumxy - sumx*sumy) / sqrt( (sumx2 - SQR(sumx)) * (sumy2 - SQR(sumy)) );
133 Float
getM()
const {
return m; }
139 Float
getB()
const {
return b; }
145 Float
getR()
const {
return r; }
157 #endif //GRT_MEAN_SHIFT_HEADER virtual bool clear() override
MLBase(const std::string &id="", const BaseType type=BASE_TYPE_NOT_SET)
bool solve(const VectorFloat &x, const VectorFloat &y)
This is the main base class that all GRT machine learning algorithms should inherit from...