Ignore:
Timestamp:
Jan 6, 2007, 12:02:21 PM (16 years ago)
Author:
Peter
Message:

fixes #167 and #160

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/test/regression_test.cc

    r729 r730  
    120120  *error << "  testing regression::LinearWeighted" << std::endl;
    121121  regression::LinearWeighted linear_w;
     122  ok = equal(linear, linear_w, error) && ok;
    122123  linear_w.fit(x,y,w);
    123124  double y_predicted = linear_w.predict(1990);
     
    134135  regression::NaiveWeighted naive_w;
    135136  regression::Naive naive;
    136   ok = ok && equal(naive, naive_w, error);
     137  ok = equal(naive, naive_w, error) && ok;
    137138  naive_w.fit(x,y,w);
    138139
     
    145146    ok=false;
    146147  }
    147 
    148148
    149149  // testing regression::Local
     
    183183  }
    184184
    185   *error << "  testing regression::Linear" << std::endl;
    186   regression::Linear lin;
    187  
    188185  *error << "  testing regression::PolynomialWeighted" << std::endl;
    189186  regression::PolynomialWeighted pol_weighted(2);
     
    225222    *error << "Error: predict not equal" << std::endl;
    226223  }
    227   if (r.prediction_error2(2000) != rw.prediction_error2(2000)){
    228     ok = false;
    229     *error << "Error: prediction_error2 not equal non-weighted version."
    230            << std::endl;
    231   }
    232   if (r.r2() != rw.r2()){
     224  if (fabs(r.prediction_error2(2000)-rw.prediction_error2(2000))>10e-7){
     225    ok = false;
     226    *error << "Error: prediction_error2 not equal non-weighted version.\n"
     227           << "       weighted: " << rw.prediction_error2(2000) << "\n"
     228           << "   non-weighted: " << r.prediction_error2(2000)
     229           << std::endl;
     230  }
     231  if (fabs(r.s2()-rw.s2())>10E-7){
    233232    ok = false;
    234233    *error << "Error: r2 not equal non-weighted version." << std::endl;
    235   }
    236   if (r.s2() != rw.s2()){
     234    *error << "weighted r2 = " << rw.r2() << std::endl;
     235    *error << "non-weighted r2 = " << r.r2() << std::endl;
     236  }
     237  if (fabs(r.s2()-rw.s2())>10E-7){
    237238    ok = false;
    238239    *error << "Error: s2 not equal non-weighted version." << std::endl;
    239   }
    240   if (r.standard_error2(2000) != rw.standard_error2(2000)){
     240    *error << "weighted s2 = " << rw.s2() << std::endl;
     241    *error << "non-weighted s2 = " << r.s2() << std::endl;
     242  }
     243  if (fabs(r.standard_error2(2000)-rw.standard_error2(2000))>10e-7){
    241244    ok = false;
    242245    *error << "Error: standard_error not equal non-weighted version."
     
    279282    *error << "Error: s2 not equal after rescaling.\n";
    280283    *error << "       s2 = " << s2 << " and after doubling weights.\n";
    281     *error << "       s2 = " << wr.s2() << "\n";
     284    *error << "       s2 = " << wr.s2(2) << "\n";
    282285  }
    283286  if (wr.standard_error2(2000) != standard_error2){
Note: See TracChangeset for help on using the changeset viewer.