分类预测 | MATLAB实现WOA-FS-SVM鲸鱼算法同步优化特征选择结合支持向量机分类预测
目录
- 分类预测 | MATLAB实现WOA-FS-SVM鲸鱼算法同步优化特征选择结合支持向量机分类预测
- 效果一览
- 基本介绍
- 程序设计
- 参考资料
效果一览
基本介绍
MATLAB实现WOA-FS-SVM鲸鱼算法同步优化特征选择结合支持向量机分类预测(完整程序和数据)
WOA鲸鱼算法同步优化特征选择结合支持向量机分类预测,优化前后对比,基于LIBSVM。
程序设计
- 完整程序和数据下载方式私信博主回复:MATLAB实现WOA-FS-SVM鲸鱼算法同步优化特征选择结合支持向量机分类预测
%% 参数设置
% 定义优化参数的个数,在该场景中,优化参数的个数为数据集特征总数 。
%目标函数
fobj = @(x) fun(x,train_wine_labels,train_wine,test_wine_labels,test_wine);
% 优化参数的个数 特征维度
dim = size(train_wine,2); %特征维度
% 优化参数的取值下限,[0,1],大于0.5为选择该特征,小于0.5为不选择该特征
lb = 0;
ub = 1;%% 参数设置
pop =10; %数量
Max_iteration=50;%最大迭代次数
%% 优化(这里主要调用函数)
[Best_score,Best_pos,curve]=WOA(pop,Max_iteration,lb,ub,dim,fobj);
figure
plot(curve,'linewidth',1.5);
xlabel('迭代次数');
ylabel('适应度值');
title('收敛曲线');
grid on;c = 2;
g = 2;
toc
% 用优化得到的特征进行训练和测试
cmd = ['-s 0 -t 2 ', '-c ', num2str(c), ' -g ', num2str(g), ' -q'];
model = libsvmtrain(train_wine_labels, train_wineNew, cmd);
test_wineNew = test_wine(:,B);
%% SVM网络预测
[predict_labelTrain, accuracyTrain,~] = libsvmpredict(train_wine_labels, train_wineNew, model);
[predict_labelTest, accuracyTest,~] = libsvmpredict(test_wine_labels, test_wineNew, model);%% 基础SVM预测结果
% 用优化得到的特征进行训练和测试
cmd = ['-s 0 -t 2 ', '-c ', num2str(c), ' -g ', num2str(g), ' -q'];
model = libsvmtrain(train_wine_labels, train_wine, cmd);
%% SVM网络预测
[predict_labelTrain1, accuracyTrain1,~] = libsvmpredict(train_wine_labels, train_wine, model);
[predict_labelTest1, accuracyTest1,~] = libsvmpredict(test_wine_labels, test_wine, model);%% 结果分析
参考资料
[1] https://blog.csdn.net/kjm13182345320/article/details/128163536?spm=1001.2014.3001.5502
[2] https://blog.csdn.net/kjm13182345320/article/details/128151206?spm=1001.2014.3001.5502