-
Notifications
You must be signed in to change notification settings - Fork 13
/
Result.m
50 lines (42 loc) · 1.42 KB
/
Result.m
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
% =====================================================================
% This class contains some properties to store experiment results, and some
% helper methods.
% =====================================================================
classdef Result < handle
properties
MAE
NMAE
RMSE
hitRate
nilElement
hoyerSparsity
cppRate
itemHits = []
coverageRate = 0;
precision
recall
f1
end
methods
function resetItemHits(obj, itemCount)
obj.itemHits = zeros(itemCount, 1);
end
function increaseItemHitsInList(obj, topNList)
for itemIndex = topNList
obj.itemHits(itemIndex) = obj.itemHits(itemIndex) + 1;
end
end
function obj = setErrorMetrics(obj, experiment, totalError, predictionCount)
obj.MAE = totalError / predictionCount;
range = (max(max(experiment.baseSet(:,:))) - min(min((experiment.baseSet(:, :)))));
obj.NMAE = obj.MAE / range;
end
function obj = setRMSE(obj, totalSquaredError, predictionCount)
obj.RMSE = sqrt(totalSquaredError/predictionCount);
end
function setCoverageRate(obj)
indexes = find(obj.itemHits ~= 0);
obj.coverageRate = length(indexes)/length(obj.itemHits);
end
end
end