0001 function cs = slcumuscore(scores, clabels, qlabels, op, maxr)
0002
0003
0004
0005
0006
0007
0008
0009
0010
0011
0012
0013
0014
0015
0016
0017
0018
0019
0020
0021
0022
0023
0024
0025
0026
0027
0028
0029
0030
0031
0032
0033
0034
0035
0036
0037
0038
0039
0040 if nargin < 4
0041 raise_lackinput('slcumuscore', 4);
0042 end
0043 if ndims(scores) ~= 2
0044 error('sltoolbox:invaliddims', ...
0045 'The matrix scores should be a 2D matrix');
0046 end
0047 [nclasses, nsamples] = size(scores);
0048 qlabels = qlabels(:);
0049 clabels = clabels(:);
0050 if length(clabels) ~= nclasses || length(qlabels) ~= nsamples
0051 error('sltoolbox:sizmismatch', ...
0052 'the labels vectors do not match the size of scores');
0053 end
0054
0055 if nargin < 5 || isempty(maxr)
0056 maxr = nclasses;
0057 end
0058
0059
0060 switch op
0061 case 'low'
0062 [ss, sp] = sort(scores, 1, 'ascend');
0063 case 'high'
0064 [ss, sp] = sort(scores, 1, 'descend');
0065 otherwise
0066 error('sltoolbox:invalidarg', ...
0067 'Invalid option %s for slcumuscore', op);
0068 end
0069 slignorevars(ss);
0070
0071 if maxr < nclasses
0072 sp = sp(1:maxr, :);
0073 else
0074 maxr = nclasses;
0075 end
0076 decisions = clabels(sp);
0077 matches = (decisions == repmat(qlabels', [maxr, 1]));
0078
0079 cs = cumsum(sum(matches, 2), 1) / nsamples;
0080
0081