Browse Source

Restoring authorship annotation for <vnik@yandex-team.ru>. Commit 2 of 2.

vnik 3 years ago
parent
commit
eeb44fff3b

+ 3 - 3
library/cpp/linear_regression/linear_model.h

@@ -7,7 +7,7 @@
 
 #include <utility>
 
-class TLinearModel { 
+class TLinearModel {
 private:
     TVector<double> Coefficients;
     double Intercept;
@@ -30,11 +30,11 @@ public:
     const TVector<double>& GetCoefficients() const {
         return Coefficients;
     }
- 
+
     double GetIntercept() const {
         return Intercept;
     }
- 
+
     template <typename T>
     double Prediction(const TVector<T>& features) const {
         return InnerProduct(Coefficients, features, Intercept);

+ 9 - 9
library/cpp/linear_regression/linear_regression.cpp

@@ -41,8 +41,8 @@ bool TFastLinearRegressionSolver::Add(const TVector<double>& features, const dou
     *olsVectorElement += weightedGoal;
 
     SumSquaredGoals += goal * goal * weight;
- 
-    return true; 
+
+    return true;
 }
 
 bool TLinearRegressionSolver::Add(const TVector<double>& features, const double goal, const double weight) {
@@ -59,7 +59,7 @@ bool TLinearRegressionSolver::Add(const TVector<double>& features, const double
 
     SumWeights += weight;
     if (!SumWeights.Get()) {
-        return false; 
+        return false;
     }
 
     for (size_t featureNumber = 0; featureNumber < featuresCount; ++featureNumber) {
@@ -109,8 +109,8 @@ bool TLinearRegressionSolver::Add(const TVector<double>& features, const double
     const double oldGoalsMean = GoalsMean;
     GoalsMean += weight * (goal - GoalsMean) / SumWeights.Get();
     GoalsDeviation += weight * (goal - oldGoalsMean) * (goal - GoalsMean);
- 
-    return true; 
+
+    return true;
 }
 
 TLinearModel TFastLinearRegressionSolver::Solve() const {
@@ -147,10 +147,10 @@ double TLinearRegressionSolver::SumSquaredErrors() const {
     return ::SumSquaredErrors(LinearizedOLSMatrix, OLSVector, coefficients, GoalsDeviation);
 }
 
-bool TSLRSolver::Add(const double feature, const double goal, const double weight) { 
+bool TSLRSolver::Add(const double feature, const double goal, const double weight) {
     SumWeights += weight;
     if (!SumWeights.Get()) {
-        return false; 
+        return false;
     }
 
     const double weightedFeatureDiff = weight * (feature - FeaturesMean);
@@ -163,8 +163,8 @@ bool TSLRSolver::Add(const double feature, const double goal, const double weigh
     GoalsDeviation += weightedGoalDiff * (goal - GoalsMean);
 
     Covariation += weightedFeatureDiff * (goal - GoalsMean);
- 
-    return true; 
+
+    return true;
 }
 
 bool TSLRSolver::Add(const double* featuresBegin,

+ 8 - 8
library/cpp/linear_regression/linear_regression.h

@@ -56,7 +56,7 @@ private:
     TStoreType SumWeights = TStoreType();
 
 public:
-    bool Add(const double feature, const double goal, const double weight = 1.) { 
+    bool Add(const double feature, const double goal, const double weight = 1.) {
         SumFeatures += feature * weight;
         SumSquaredFeatures += feature * feature * weight;
 
@@ -66,8 +66,8 @@ public:
         SumProducts += goal * feature * weight;
 
         SumWeights += weight;
- 
-        return true; 
+
+        return true;
     }
 
     template <typename TFloatType>
@@ -140,7 +140,7 @@ private:
     double Covariation = 0.;
 
 public:
-    bool Add(const double feature, const double goal, const double weight = 1.); 
+    bool Add(const double feature, const double goal, const double weight = 1.);
 
     bool Add(const double* featuresBegin, const double* featuresEnd, const double* goalsBegin);
     bool Add(const double* featuresBegin, const double* featuresEnd, const double* goalsBegin, const double* weightsBegin);
@@ -188,8 +188,8 @@ public:
         for (size_t featureNumber = 0; featureNumber < features.size(); ++featureNumber) {
             SLRSolvers[featureNumber].Add(features[featureNumber], goal, weight);
         }
- 
-        return true; 
+
+        return true;
     }
 
     TLinearModel Solve(const double regularizationParameter = 0.1) const {
@@ -201,9 +201,9 @@ public:
         }
 
         TVector<double> coefficients(SLRSolvers.size());
-        double intercept = 0.0; 
+        double intercept = 0.0;
         if (bestSolver) {
-            bestSolver->Solve(coefficients[bestSolver - SLRSolvers.begin()], intercept, regularizationParameter); 
+            bestSolver->Solve(coefficients[bestSolver - SLRSolvers.begin()], intercept, regularizationParameter);
         }
 
         TLinearModel model(std::move(coefficients), intercept);