summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--calc_error.m3
-rw-r--r--run_tests.m9
2 files changed, 5 insertions, 7 deletions
diff --git a/calc_error.m b/calc_error.m
index 7204715..2f7e9c6 100644
--- a/calc_error.m
+++ b/calc_error.m
@@ -1,7 +1,8 @@
-function [quad, total] = calc_error(name, data, pred)
+function [quad, total, local] = calc_error(name, data, pred)
quad = quad_error(data, round(pred));
total = total_error(data, round(pred));
+ local = sum(abs(data - round(pred)));
printf('%-11s quad: %d\t total: %d\n', name, quad, total);
diff --git a/run_tests.m b/run_tests.m
index 4e6b1d5..2240f43 100644
--- a/run_tests.m
+++ b/run_tests.m
@@ -22,17 +22,14 @@ for i = 1:num_methods
pred_list{i} = pred_methods{i}{2}(p, train_data);
end
-qerr = zeros(1, num_methods);
-terr = zeros(1, num_methods);
+qerr = terr = zeros(1, num_methods);
err = zeros(num_methods, size(real_data,2));
for i = 1:num_methods
- [qerr(i), terr(i)] = calc_error(pred_methods{i}{1}, real_data, pred_list{i});
- err(i, :) = sum(abs(real_data - pred_list{i}));
+ [qerr(i), terr(i), err(i, :)] = calc_error(pred_methods{i}{1}, real_data, pred_list{i});
end
opt_data = opt_pred(real_data, pred_list);
-[opqerr, opterr] = calc_error('optimize', real_data, opt_data);
-opt_err = sum(abs(real_data - opt_data));
+[opqerr, opterr, opt_err] = calc_error('optimize', real_data, opt_data);
qerr = [ qerr opqerr ];
terr = [ terr opterr ];