summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBenjamin Franzke <benjaminfranzke@googlemail.com>2012-05-11 11:33:25 +0200
committerBenjamin Franzke <benjaminfranzke@googlemail.com>2012-05-11 11:33:25 +0200
commitadecf91d28868fe604fb0db9984bbe609d567aca (patch)
treead98bb6ecccf7b0c0734a6519dec7c90741ed3c3
parentf38c08a5b555a846a0d4c224f617b08ffd86a28d (diff)
downloaddmc-adecf91d28868fe604fb0db9984bbe609d567aca.tar.gz
dmc-adecf91d28868fe604fb0db9984bbe609d567aca.tar.bz2
dmc-adecf91d28868fe604fb0db9984bbe609d567aca.zip
Put local error calculation into calc_error
-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 ];