blob: 90b3dd9437dcfbc25cfd085b0d35b8f6b66839ea (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
|
function [quad, total, local] = calc_error(name, data, pred)
quad_error = @(a, b) sqrt(sum(sum((a - b) .^ 2)));
total_error = @(a, b) sum(sum(abs(a - b)));
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);
%plot((sum(abs(data - pred))), '-ob;unsorted;');
%hold on;
%plot(sort(sum(abs(data - pred))), '-or;sorted;');
%hold off;
%xlabel('products');
%ylabel('total error');
end
|