资源简介
Feature scaling for kernel Fisher discriminant analysis using leave-one-out cross validation. FS-KFDA is a package for implementing feature scaling for kernel fisher discriminant analysis.-Feature scaling for kernel Fisher discrim inant analysis using leave-one-out cross vali dation. FS-KFDA is a package for implementing f eature scaling for kernel fisher discriminant analysis.
代码片段和文件信息
clear
load blfsegment;
load segmentindex;
trainnum = 500;
starttime = cputime;
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
for k = 1:10
% Tanslate the data
index1 = segmentindex(k1:trainnum);
index2 = segmentindex(k1+trainnum:end);
trainsamples = segmentsamples(index1:);
testsamples = segmentsamples(index2:);
[trainsamplesAB]= scaletrain(trainsamples);
testsamples = scaletest(testsamplesAB);
trainlabels = segmentlabels(index1);
testlabels = segmentlabels(index2);
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% calculate the correct rate
options = optimset(‘GradObj‘‘on‘);
options = optimset(options‘LargeScale‘‘off‘);
options = optimset(options‘DerivativeCheck‘‘off‘);
options = optimset(options‘Display‘‘iter‘);
options = optimset(options‘MaxIter‘50);
options = optimset(options‘TolFun‘1e-4);
options = optimset(options‘TolX‘1e-4);
options = optimset(options‘LineSearchType‘‘cubicpoly‘);
D = size(trainsamples2);
x = log(1/D)*ones(size(trainsamples2)1);
[xfxc] = fminunc(‘mkfdakernel‘[x;0*ones(11)]optionstrainsamplestrainlabels);
[abloo(k)] = mkfdakernel(xtrainsamplestrainlabels);
fprintf(‘%f\n‘loo(k));
result = mkfdapred(x trainsamples trainlabelstestsamples);
testerror(k) = 1 - mean(result == testlabels);
fprintf(‘meanerror = %f\n‘mean(testerror));
fprintf(‘Iteration = %d\n‘k);
end
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% print the output
endtime = cputime;
meanerror = mean(testerror);
stderror = std(testerror);
fprintf(‘meanerror = %f\n‘meanerror);
fprintf(‘stderror = %f\n‘stderror);
fprintf(‘time = %f\n‘endtime-starttime);
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
属性 大小 日期 时间 名称
----------- --------- ---------- ----- ----
文件 2501 2006-10-10 20:18 fs-kfda 1.0\bench_segment.m
文件 335224 2006-10-10 17:39 fs-kfda 1.0\blfsegment.mat
文件 712 2006-10-10 20:26 fs-kfda 1.0\content.m
文件 568 2006-01-16 11:05 fs-kfda 1.0\evalkernel.m
文件 1749 2005-07-08 11:22 fs-kfda 1.0\kfdakernel.m
文件 1186 2005-06-29 11:13 fs-kfda 1.0\kfdapred.m
文件 2127 2005-04-08 20:18 fs-kfda 1.0\mkfdakernel.m
文件 1525 2005-04-06 20:36 fs-kfda 1.0\mkfdapred.m
文件 180 2005-01-21 20:18 fs-kfda 1.0\scaletest.m
文件 231 2005-06-11 09:41 fs-kfda 1.0\scaletrain.m
文件 380757 2006-10-10 19:22 fs-kfda 1.0\segmentindex.mat
文件 380 2011-03-07 11:24 fs-kfda 1.0\注释.txt
目录 0 2006-10-10 20:15 fs-kfda 1.0
----------- --------- ---------- ----- ----
727140 13
评论
共有 条评论