fda_test.m
来自「Fisher线性判别分类器源代码」· M 代码 · 共 31 行
M
31 行
function LABEL_TEST=FDA_TEST(SAMPLES,WEIGHTS,INTERCEPT);
%Use the trained Fisher linear classifier to classify data
%USAGE: LABEL_TEST=FDA_TEST(SAMPLES,WEIGHTS,INTERCEPT)
%INPUT:
%SAMPLES is a matrix for the data to be classified, each column is a data
%sample, [WEIGHTS,INTERCEPT] are parameters for the classifier obtained by
%the training process from 'FDA_TRAIN'
%OUTPUT:
%LABEL_TEST is a row vector of the classification results for SAMPLES,
%the label will be given as -1/1 for the two classes
%
%See also: FDA_TRAIN
%
% Dan.Zhang 2006-08-17
% d-zhang@mails.tsinghua.edu.cn
if(nargin~=3)
fprintf('Error: Not the Correct Input.\n');
return;
end
DimNum=size(SAMPLES,1);
WeiNum=size(WEIGHTS,2);
if(DimNum~=WeiNum)
fprintf('Error: SAMPLES and WEIGHTS mismatch.\n');
return;
end
LABEL_TEST=WEIGHTS*SAMPLES-INTERCEPT;
LABEL_TEST(find(LABEL_TEST>=0))=1;
LABEL_TEST(find(LABEL_TEST<0))=-1;
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?