Average error on the test set INPUT PARAMETERS: LM - linear model XY - test set NPoints - test set size RESULT: average error. -- ALGLIB -- Copyright 30.08.2008 by Bochkanov Sergey *************************************************************************/
| 526 | Copyright 30.08.2008 by Bochkanov Sergey |
| 527 | *************************************************************************/ |
| 528 | double lravgerror(const linearmodel& lm, |
| 529 | const ap::real_2d_array& xy, |
| 530 | int npoints) |
| 531 | { |
| 532 | double result; |
| 533 | int i; |
| 534 | double v; |
| 535 | int offs; |
| 536 | int nvars; |
| 537 | |
| 538 | ap::ap_error::make_assertion(ap::round_f(lm.w(1))==lrvnum, "LINREG: Incorrect LINREG version!"); |
| 539 | nvars = ap::round_f(lm.w(2)); |
| 540 | offs = ap::round_f(lm.w(3)); |
| 541 | result = 0; |
| 542 | for(i = 0; i <= npoints-1; i++) |
| 543 | { |
| 544 | v = ap::vdotproduct(&xy(i, 0), 1, &lm.w(offs), 1, ap::vlen(0,nvars-1)); |
| 545 | v = v+lm.w(offs+nvars); |
| 546 | result = result+fabs(v-xy(i,nvars)); |
| 547 | } |
| 548 | result = result/npoints; |
| 549 | return result; |
| 550 | } |
| 551 | |
| 552 | |
| 553 | /************************************************************************* |
no test coverage detected