/usr/share/octave/packages/nan-2.5.9/classify.m is in octave-nan 2.5.9-2.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
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 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 | function [CLASS,ERR,POSTERIOR,LOGP,COEF]=classify(sample,training,classlabel,TYPE)
% CLASSIFY classifies sample data into categories
% defined by the training data and its group information
%
% CLASS = classify(sample, training, group)
% CLASS = classify(sample, training, group, TYPE)
% [CLASS,ERR,POSTERIOR,LOGP,COEF] = CLASSIFY(...)
%
% CLASS contains the assigned group.
% ERR is the classification error on the training set weighted by the
% prior propability of each group.
%
% The same classifier as in TRAIN_SC are supported.
%
% ATTENTION: no cross-validation is applied, therefore the
% classification error is too optimistic (overfitting).
% Use XVAL instead to obtain cross-validated performance.
%
% see also: TRAIN_SC, TEST_SC, XVAL
%
% References:
% [1] R. Duda, P. Hart, and D. Stork, Pattern Classification, second ed.
% John Wiley & Sons, 2001.
% $Id$
% Copyright (C) 2008,2009 by Alois Schloegl <alois.schloegl@gmail.com>
% This function is part of the NaN-toolbox
% http://pub.ist.ac.at/~schloegl/matlab/NaN/
% This program is free software; you can redistribute it and/or
% modify it under the terms of the GNU General Public License
% as published by the Free Software Foundation; either version 3
% of the License, or (at your option) any later version.
%
% This program is distributed in the hope that it will be useful,
% but WITHOUT ANY WARRANTY; without even the implied warranty of
% MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
% GNU General Public License for more details.
%
% You should have received a copy of the GNU General Public License
% along with this program; if not, write to the Free Software
% Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston, MA 02110-1301, USA.
if nargin<4
TYPE = 'linear';
end;
if strcmp(TYPE,'linear')
TYPE = 'LDA';
elseif strcmp(TYPE,'quadratic')
TYPE = 'QDA2'; % result is closer to Matlab
elseif strcmp(TYPE,'diagLinear')
TYPE = 'NBC';
elseif strcmp(TYPE,'diagQuadratic')
TYPE = 'NBC';
elseif strcmp(TYPE,'mahalanobis')
TYPE = 'MDA';
end;
[group,I,classlabel] = unique(classlabel);
CC = train_sc(training,classlabel,TYPE);
R = test_sc(CC,sample);
CLASS = group(R.classlabel);
if nargout>1,
R = test_sc(CC,training,[],classlabel);
ERR = 1-R.ACC;
end;
if nargout>2,
warning('output arguments POSTERIOR,LOGP and COEF not supported')
POSTERIOR = [];
LOGP = [];
COEF = [];
end;
|