Browse Source

Implemented regression via RANSAC-Algorithm and according testframe.

Frank Prüfer 11 years ago
parent
commit
4f756bd189
1 changed files with 11 additions and 9 deletions
  1. 11 9
      regression/linregression/LinRegression.cpp

+ 11 - 9
regression/linregression/LinRegression.cpp

@@ -15,11 +15,13 @@ using namespace std;
 
 using namespace NICE;
 
-LinRegression::LinRegression(){
+LinRegression::LinRegression()
+{
   dim = 0;
 }
 
-LinRegression::LinRegression(uint dimension){
+LinRegression::LinRegression(uint dimension)
+{
   dim = dimension;
 }
 
@@ -27,21 +29,19 @@ LinRegression::LinRegression ( const LinRegression & src ) :
 RegressionAlgorithm ( src )
 {
 dim = src.dim;
+modelParams = src.modelParams;
 }
 
 LinRegression::~LinRegression()
 {
 }
 
-void LinRegression::teach ( const NICE::VVector & x, const NICE::Vector & y ){
-  
+void LinRegression::teach ( const NICE::VVector & x, const NICE::Vector & y )
+{  
   if (dim == 0){	//dimension not specified via constructor
     dim = x[0].size()+1;  //use full dimension of data
   }
   
-  cerr<<"dim: "<<dim<<endl;
-  cerr<<"examples: "<<x.size()<<endl;
-  
   for ( uint i = 0;i < dim;i++ ){  //initialize vector of model parameters
     modelParams.push_back(0.0);
   }
@@ -106,11 +106,13 @@ void LinRegression::teach ( const NICE::VVector & x, const NICE::Vector & y ){
   }
 }
 
-std::vector<double> LinRegression::getModelParams(){
+std::vector<double> LinRegression::getModelParams()
+{
   return modelParams;
 }
 
-double LinRegression::predict ( const NICE::Vector & x ){
+double LinRegression::predict ( const NICE::Vector & x )
+{
   double y;
   if ( dim == 2 ){  //two-dimensional least squares
     y = modelParams[0] + modelParams[1] * x[0];