资源简介
采用了,核函数Fisher鉴别准则,分类。
代码片段和文件信息
function [Train_FeatureTest_Feature]=GetFeature_KFDA(Train_SampleTest_SampleSample);
%使用核Fisher方法对样本进行特征提取
sn_ori=size(Sample2);
Train_Num=5;
[Dim_orisncn]=size(Sample);
Test_Num=sn-Train_Num;
Train_count=Train_Num*cn;
Test_count=Test_Num*cn;
[Train_Feature2Test_Feature2]=GetProjection(SampleTrain_NumTrain_SampleTest_Sample);
%训练样本,测试样本分别二维变成三维
[dimn]=size(Train_Feature2);
T=ones(dimTrain_Numcn);
for i=1:cn
T1=[];
for j=1:Train_Num
T1=[T1 Train_Feature2(:(i-1)*Train_Num+j)];
end
T(::i)=T1;
end
Train_Feature3=T;
T=ones(dimTest_Numcn);
for i=1:cn
T1=[];
for j=1:Test_Num
T1=[T1 Test_Feature2(:(i-1)*Test_Num+j)];
end
T(::i)=T1;
end
Test_Feature3=T;
%在训练样本的KPCA特征矩阵上求得散布矩阵Sb、Sw、St
[SbSwSt]=GetScatter(Train_Feature3);
[VS]=eig(Sw);
s=diag(S);
[sindex]=sort(s‘descend‘);
Rank_Sw=rank(Sw);
%取Sw的零空间
k=1;
for i=(Rank_Sw+1):size(Sw1)
P1(:k)=V(:index(i));
k=k+1;
end
Sb1=P1‘*Sb*P1;
Rank_SbI=rank(Sb1);
[V1S1]=eig(Sb1);
s1=diag(S1);
[s1index1]=sort(s1‘descend‘);
for i=1:Rank_SbI
Z1(:i)=V1(:index1(i));
end
W1=P1*Z1;
%取P1的正交补空间
for i=1:Rank_Sw
P2(:i)=V(:index(i));
end
Sb2=P2‘*Sb*P2;
St2=P2‘*St*P2;
[V2S2]=eig(Sb2St2);
s2=diag(S2);
[s2index2]=sort(s2‘descend‘);
k=1;
for j=1:size(s21)
if s2(j)>1e-6
Z2(:k)=V2(:index2(j));
k=k+1;
end
end
W2=P2*Z2;
W=[W1W2];
ProjectSet=W;
%降维,由于 rank((Sw^-1)*Sb) <= rank(Sb) <= K-1,所以非零的特征根的个数最多为K-1。所以可以到 K-1 维。
ProjectSet=ProjectSet(:1:sn-1);
%特征提取
Train_Feature=ProjectSet‘*Train_Feature2;
Test_Feature=ProjectSet‘*Test_Feature2;
%训练样本,测试样本分别二维变成三维
[dimn]=size(Train_Feature);
T=ones(dimTrain_Numcn);
for i=1:cn
T1=[];
for j=1:Train_Num
T1=[T1 Train_Feature(:(i-1)*Train_Num+j)];
end
T(::i)=T1;
end
Train_Feature=T;
T=ones(dimTest_Numcn);
for i=1:cn
T1=[];
for j=1:Test_Num
T1=[T1 Test_Feature(:(i-1)*Test_Num+j)];
end
T(::i)=T1;
end
Test_Feature=T;
属性 大小 日期 时间 名称
----------- --------- ---------- ----- ----
文件 2187 2008-06-15 17:45 KFDA\GetFeature_KFDA.m
文件 704 2008-06-15 16:03 KFDA\GetProjection.m
文件 800 2008-06-13 21:38 KFDA\GetScatter.m
文件 2620 2008-06-13 16:49 KFDA\kpca_calc.m
文件 738 2008-06-12 21:34 KFDA\kpca_map.m
文件 1024 2006-03-27 22:52 KFDA\kpca_matrix.m
文件 567 2008-06-15 17:51 KFDA\main.m
文件 1201 2008-06-14 11:27 KFDA\ReadImage.m
文件 758 2008-06-15 11:00 KFDA\Recognition.m
目录 0 2008-06-15 17:56 KFDA
----------- --------- ---------- ----- ----
10599 10
- 上一篇:小波变换分析故障振动信号
- 下一篇:数据集bank.arff
评论
共有 条评论