✅作者简介:热爱科研的Matlab仿真开发者,修心和技术同步精进,matlab项目合作可私信。
🍎个人主页:Matlab科研工作室
🍊个人信条:格物致知。
更多Matlab仿真内容点击👇
⛄ 内容介绍
通过将极限学习机 (ELM) 和稀疏表示 (SRC) 结合到一个统一的框架中,所提出的混合分类器不仅具有快速测试的优势(ELM 的优点),而且还显示出显着的分类精度(SRC 的优点)。我们对其进行 AR 人脸识别测试,其准确率达到 95%,优于 ELM(91%)和 SRC(93.5%)。
ELM 和 SRC 之间的桥梁是 ELM 错误分类指标和自适应蛋白质类别选择。
更详细的内容可以参考论文《罗敏,张凯. 一种结合极限学习机和稀疏表示的混合图像分类方法[J]. 人工智能工程应用, 2014, 27: 228-235.]。
请注意,它是上述论文的改进版本
⛄ 部分代码
clc;clear all;
load pca_datasets.mat;
num_nodes=1000; % hidden nodes number
C=1e0;
alpha=0.2;
kclass=length(unique(trainlabel))/2; % for adaptive class domain selection
traindata = traindata./( repmat(sqrt(sum(traindata.*traindata)), [size(traindata,1),1]) );
testdata = testdata./(repmat(sqrt(sum(testdata.*testdata)), [size(testdata,1),1]) );
% [traindata,PS] = mapminmax(traindata,-1,1);%
% testdata = mapminmax('apply',testdata,PS);
% [traindata,PS] = mapstd(traindata);%
% testdata = mapstd('apply',testdata,PS);
rng(1);
tic;
[TrainingAccuracy,InputWeight, BiasofHiddenNeurons, OutputWeight,NumberofOutputNeurons,...
label] = elm_train(traindata,trainlabel,num_nodes,C);
trainingtime=toc;
ID = [];
IDe = [];
lamda = 1e-3;
tol = 1e-2;
tic;
f = 0;
for i = 1 : size(testdata,2)
[id, Tdiff, T] = elm_predict(testdata(:,i), InputWeight, BiasofHiddenNeurons, OutputWeight);
IDe = [IDe, id];
if Tdiff > alpha
ID = [ID, id];
if id ~= testlabel(i)
fprintf('Wrong classification for %1.0f th testing sample by ELM criterion (|T_first - T_second| = %1.2f) \n ', i, Tdiff);
end
else
f = f + 1;
[sim, slabel]=sort(T, 'descend');
newtrainlabel = trainlabel(ismember(trainlabel,slabel(1:kclass)));
newtraindata = traindata(:,ismember(trainlabel,slabel(1:kclass)));
y = testdata(:,i);
s = l1_ls(newtraindata, y, lamda, tol, 1);
% s=l1_ls_nonneg(newtraindata,y,5e-2,1e-7,1);
newlabel = unique(newtrainlabel);
if ~ismember(testlabel(i), newlabel)
fprintf('Wrong classification for %1.0f th testing sample by ELM criterion (|Adaptive class domain|) \n ', i);
end
for indClass = 1 : length(newlabel)
coef_c = s(newtrainlabel==newlabel(indClass));
Dc = newtraindata(:,newtrainlabel==newlabel(indClass));
gap(indClass) = norm(y-Dc*coef_c)^2;
end
wgap3 = gap ;
index3 = find(wgap3==min(wgap3));
id3 = index3(1);
id = newlabel(id3);
fprintf('%1.0f / %1.0f %1.0f %1.3f %1.0f %1.2f %1.0f \n', i, size(testdata,2), f, sum(s), find(slabel==testlabel(i)), Tdiff, id==testlabel(i));
ID = [ID, id];
end
end
testingtime=toc;
Rec_ELM = sum(IDe==testlabel)/length(testlabel);
Rec_ELMSRC = sum(ID==testlabel)/length(testlabel); % recognition rate
disp(['ELM recogniton rate is ' num2str(Rec_ELM)]);
disp(['ELMSRC recogniton rate is ' num2str(Rec_ELMSRC)]);
figure
plot(testlabel,'bs-');hold on
plot(IDe,'ro-');hold on
plot(ID,'g*-');hold on
legend('真实值','ELM','ELMSRC')
xlabel('样本')
ylabel('类别')
⛄ 运行结果
⛄ 参考文献
《罗敏,张凯. 一种结合极限学习机和稀疏表示的混合图像分类方法[J]. 人工智能工程应用, 2014, 27: 228-235.]。
⛄ 完整代码
❤️部分理论引用网络文献,若有侵权联系博主删除
❤️ 关注我领取海量matlab电子书和数学建模资料