summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--calc_error.m12
-rw-r--r--run_tests.m8
2 files changed, 11 insertions, 9 deletions
diff --git a/calc_error.m b/calc_error.m
index 1f525ba..7ed3a5e 100644
--- a/calc_error.m
+++ b/calc_error.m
@@ -1,13 +1,15 @@
-function calc_error(data, pred)
+function calc_error(name, data, pred)
quad = quad_error(data, pred);
total = total_error(data, pred);
- printf('quad mean : %9d\n', quad);
- printf('total mean : %9d\n', total);
+ printf('%9s quad: %9d\n', name, quad);
+ printf('%9s total: %9d\n', name, total);
- plot((sum(abs(data - pred))), 'b');
+ xlabel('products');
+ ylabel('total error');
+ plot((sum(abs(data - pred))), '-ob;unsorted;');
hold on;
- plot(sort(sum(abs(data - pred))), 'r');
+ plot(sort(sum(abs(data - pred))), '-or;sorted;');
hold off;
end
diff --git a/run_tests.m b/run_tests.m
index 031dd82..32e49cb 100644
--- a/run_tests.m
+++ b/run_tests.m
@@ -1,9 +1,9 @@
[p, q] = get_products();
% quantity sum over a day
-plot(sum(q'));
+%plot(sum(q'));
% plot prediction quallity
-calc_error(q(29:42, :), mean_pred(q(1:28, :), 14));
-calc_error(q(29:42, :), regress_pred(p, q(1:28, :)));
-calc_error(q(29:42, :), repmat(sevenday_pred(q(1:28, :), 4), 2, 1));
+calc_error('mean', q(29:42, :), mean_pred(q(1:28, :), 14));
+calc_error('regress', q(29:42, :), regress_pred(p, q(1:28, :)));
+calc_error('sevenday', q(29:42, :), repmat(sevenday_pred(q(1:28, :), 4), 2, 1));