Changeset 731 for trunk/test/regression_test.cc
 Timestamp:
 Jan 6, 2007, 5:06:19 PM (16 years ago)
 File:

 1 edited
Legend:
 Unmodified
 Added
 Removed

trunk/test/regression_test.cc
r730 r731 43 43 bool equal(regression::OneDimensional&, regression::OneDimensionalWeighted&, 44 44 std::ostream*); 45 46 bool multidim(std::ostream* error); 45 47 46 48 bool unity_weights(regression::OneDimensional&, … … 185 187 *error << " testing regression::PolynomialWeighted" << std::endl; 186 188 regression::PolynomialWeighted pol_weighted(2); 189 // ok = equal(polynomial, pol_weighted, error) && ok; 190 191 ok = multidim(error) && ok; 187 192 188 193 if (error!=&std::cerr) … … 220 225 if (r.predict(2000) != rw.predict(2000)){ 221 226 ok = false; 222 *error << "Error: predict not equal" << std::endl; 227 *error << "Error: predict not equal\n" 228 << " weighted: " << rw.predict(2000) << "\n" 229 << " nonweighted: " << r.predict(2000) 230 << std::endl; 223 231 } 224 232 if (fabs(r.prediction_error2(2000)rw.prediction_error2(2000))>10e7){ … … 340 348 341 349 350 bool multidim(std::ostream* error) 351 { 352 bool ok = true; 353 *error << " testing regression::MultiDimensionalWeighted" << std::endl; 354 utility::vector x(5); x(0)=1970; x(1)=1980; x(2)=1990; x(3)=2000; x(4)=2010; 355 utility::vector y(5); y(0)=12; y(1)=11; y(2)=14; y(3)=13; y(4)=15; 356 utility::vector w(5,1.0); 357 358 utility::matrix data(5,3); 359 for (size_t i=0; i<data.rows(); ++i){ 360 data(i,0)=1; 361 data(i,1)=x(i); 362 data(i,2)=x(i)*x(i); 363 } 364 regression::MultiDimensional md; 365 md.fit(data,y); 366 regression::MultiDimensionalWeighted mdw; 367 mdw.fit(data,y,w); 368 utility::vector z(3,1); 369 z(1)=2000; 370 z(2)=2000*2000; 371 if (md.predict(z) != mdw.predict(z)){ 372 ok = false; 373 *error << "Error: predict not equal\n" 374 << " weighted: " << mdw.predict(1) << "\n" 375 << " nonweighted: " << md.predict(1) 376 << std::endl; 377 } 378 /* 379 if (md.standard_error2(z) != mdw.standard_error2(z)){ 380 ok = false; 381 *error << "Error: standard_error2 not equal\n" 382 << " weighted: " << mdw.standard_error2(z) << "\n" 383 << " nonweighted: " << md.standard_error2(z) 384 << std::endl; 385 } 386 */ 387 return ok; 388 } 389 390 342 391 bool Local_test(regression::OneDimensionalWeighted& r, 343 392 regression::Kernel& k)
Note: See TracChangeset
for help on using the changeset viewer.