1 %> @brief Records (test
class)x([rejected, estimation class]) hits
4 %> All possible class labels in reference datasets
6 %> All possible
class labels in estimation datasets
8 %> =0. What to give
as a
"rate". 0-mean sensitivity; 1-diagonal element defined by idx_rate
10 %> =1. Diagonal element
if @c ratemode is 1.
16 o.classtitle = 'Class X Class';
22 methods(Access=protected)
23 %> Returns the contents of the @c estlabels property.
24 function z = get_collabels(o)
28 %> Returns the contents of the @c testlabels property.
29 function z = get_rowlabels(o)
33 function o = do_record(o, pars)
35 ds_test = pars.ds_test;
36 if isempty(est.classes)
37 irerror('Classes of estimation dataset are empty! Are you sure it has been put through a
decider?');
39 if numel(est.classes) ~= numel(ds_test.classes)
40 irerror('Number of items in estimation is different from number of items in reference dataset!');
43 for i = 1:numel(o.testlabels)
44 classidx = find(strcmp(o.testlabels{i}, ds_test.classlabels)); % rowlabel of turn
class index in reference dataset
46 % Class was not tested <--> not present in reference (test) dataset
48 rowidxs = ds_test.classes == classidx-1; % Indexes of rows belonging to i-th class
49 sel = estclasses(rowidxs);
51 supp = est.X(rowidxs, 1)';
55 % % Method 1: better with more classes; better with less rows
57 % difference = diff([x;max(x)+1]);
58 % count = diff(find([1;difference]));
59 % y = x(find(difference));
61 % Method 2: better with fewer classes; better with more rows
62 % Both methods are quite quick anyway
63 for j = 1:numel(o.estlabels)
64 idxidxbool = sel == j-1;
65 o.hits(i, j+1, o.t) = o.hits(i, j+1, o.t)+sum(idxidxbool);
67 o.supports{i, j+1, o.t} = supp(idxidxbool); % Assumeed that est is the output of a
decider block which produces a X with one feature only, which is the support.
71 idxidxbool = sel == -1;
72 o.hits(i, 1, o.t) = sum(idxidxbool); % Rejection count.
74 o.supports{i, 1, o.t} = supp(idxidxbool); % Assumeed that est is the output of a
decider block which produces a X with one feature only, which is the support.
82 %> Returns average of diagonal of confusion matrix.
84 %> If one row wasn
't tested, it won't enter the average calculation
85 function z = get_meandiag(o)
86 C = o.get_C([], 1, 3, 1);
87 W = o.get_weights([], 1); % (no_rows)x(no_t) matrix of weights
89 z = diag(C(:, 2:end))'*w/sum(w(:)); % Re-normalizes using weights for every element of the diagonal
92 %> Either redirects to get_meandiag() or returns diagonal element of average confusion matrix
93 function z = get_rate(o)
97 C = o.get_C([], 1, 3, 1); % Gets average percentage with discounted rejected items
98 z = C(o.idx_rate, o.idx_rate+1);
102 %> Returns vector with time-wise-calculated averages
104 %> @return If @c ratemode == 0, returns the average of the diagonal calculated for each time instant, weighted by
105 %> whether each row was tested or not; if @c ratemode > 0, returns one diagonal element for each time instant. In either case, rejected
106 %> items are discounted.
107 function z = get_rates(o)
108 CC = o.get_C([], 1, 0, 1); % gets per-time matrices of percentages
110 z(:) = CC(o.idx_rate, o.idx_rate+1, :);
112 W = o.get_weights([], 1); % (no_rows)x(no_t) matrix of weights
116 z(i) = diag(CC(:, 2:end, i))'*W(:, i); % dot product
Block that resolves estimato posterior probabilities into classes.
Estimation logs base class.
Records (test class)x([rejected, estimation class]) hits.
function renumber_classes(in classes_orig, in classlabels_orig, in classlabels_ref)
Analysis Session (AS) base class.