| 23 | } |
| 24 | |
| 25 | bool TFastLinearRegressionSolver::Add(const TVector<double>& features, const double goal, const double weight) { |
| 26 | const size_t featuresCount = features.size(); |
| 27 | |
| 28 | if (LinearizedOLSMatrix.empty()) { |
| 29 | LinearizedOLSMatrix.resize((featuresCount + 1) * (featuresCount + 2) / 2); |
| 30 | OLSVector.resize(featuresCount + 1); |
| 31 | } |
| 32 | |
| 33 | AddFeaturesProduct(weight, features, LinearizedOLSMatrix); |
| 34 | |
| 35 | const double weightedGoal = goal * weight; |
| 36 | double* olsVectorElement = OLSVector.data(); |
| 37 | for (const double feature : features) { |
| 38 | *olsVectorElement += feature * weightedGoal; |
| 39 | ++olsVectorElement; |
| 40 | } |
| 41 | *olsVectorElement += weightedGoal; |
| 42 | |
| 43 | SumSquaredGoals += goal * goal * weight; |
| 44 | |
| 45 | return true; |
| 46 | } |
| 47 | |
| 48 | bool TLinearRegressionSolver::Add(const TVector<double>& features, const double goal, const double weight) { |
| 49 | const size_t featuresCount = features.size(); |
no test coverage detected