上海建个人网站比较好的公司,07073游戏网官网,设计网站建设方案,公司邮箱注册申请分类预测 | MFO-LSSVM飞蛾扑火算法优化最小二乘支持向量机多特征分类预测Matlab实现 目录 分类预测 | MFO-LSSVM飞蛾扑火算法优化最小二乘支持向量机多特征分类预测Matlab实现分类效果基本介绍程序设计参考资料 分类效果 基本介绍
1.Matlab实现MFO-LSSVM飞蛾扑火算法优化最小二…分类预测 | MFO-LSSVM飞蛾扑火算法优化最小二乘支持向量机多特征分类预测Matlab实现 目录 分类预测 | MFO-LSSVM飞蛾扑火算法优化最小二乘支持向量机多特征分类预测Matlab实现分类效果基本介绍程序设计参考资料 分类效果 基本介绍
1.Matlab实现MFO-LSSVM飞蛾扑火算法优化最小二乘支持向量机多特征分类预测运行环境Matlab2018b及以上
2.输入12个特征输出分4类可视化展示分类准确率可在下载区获取数据和程序内容。
3.算法优化LSSVM参数为siggamma。
4.excel数据集main为主程序其他为函数文件无需运行分类效果如下
注程序和数据放在一个文件夹。
程序设计
完整程序和数据获取方式资源处直接下载MFO-LSSVM飞蛾扑火算法优化最小二乘支持向量机多特征分类预测Matlab实现完整源码和数据。
%% 清空环境变量
warning off % 关闭报警信息
close all % 关闭开启的图窗
clear % 清空变量
clc % 清空命令行%% 导入数据
res xlsread(数据集.xlsx);
%% 划分训练集和测试集%
P_train res(1: 250, 1: 12);
T_train res(1: 250, 13);
M size(P_train, 2);P_test res(251: end, 1: 12);
T_test res(251: end, 13);
N size(P_test, 2);
%% 数据归一化
[p_train, ps_input] mapminmax(P_train,0,1);
p_test mapminmax(apply,P_test,ps_input);
t_train T_train;
t_test T_test;%% LS参数设置
type c; % 模型类型 分类
kernel_type RBF_kernel; % 线性核函数
codefct code_OneVsOne; % 一对一编码分类
fun getObjValue; % 目标函数
dim 2; % 优化参数个数
ub [300, 300]; % 优化参数目标上限
lb [1, 1]; % 优化参数目标下限pop 8; % 数量
Max_iteration 20; % 最大迭代次数 c Best_pos(1);
g Best_pos(2);%% 编码
[t_train,codebook,old_codebook] code(t_train,codefct);%% 建立模型
model initlssvm(p_train,t_train,type,c,g,kernel_type,codefct); %SSA%% 训练模型
model trainlssvm(model);%% 测试模型
t_sim1 simlssvm(model,p_train);
t_sim2 simlssvm(model,p_test); T_sim1 T_sim1(index_1);
T_sim2 T_sim2(index_2);
%% 性能评价
error1 sum((T_sim1 T_train))/M * 100 ;
error2 sum((T_sim2 T_test))/N * 100 ;%% 优化曲线
figure
plot(curve, linewidth,1.5);
title(-LSSVM)
xlabel(The number of iterations)
ylabel(Fitness)
grid on;
%% 绘图
figure
plot(1: M, T_train, r-*, 1: M, T_sim1, b-o, LineWidth, 1)
legend(真实值, -LSSVM预测值)
xlabel(预测样本)
ylabel(预测结果)
string {训练集预测结果对比; [准确率 num2str(error1) %]};
title(string)
xlim([1, M])
gridfigure
plot(1: N, T_test, r-*, 1: N, T_sim2, b-o, LineWidth, 1)
legend(真实值, -LSSVM预测值)
xlabel(预测样本)
ylabel(预测结果)
string {测试集预测结果对比; [准确率 num2str(error2) %]};
title(string)
xlim([1, N])
grid%% 混淆矩阵
figure
cm confusionchart(T_train, T_sim1);
cm.Title Confusion Matrix for Train Data;
cm.ColumnSummary column-normalized;
cm.RowSummary row-normalized;figure
cm confusionchart(T_test, T_sim2);
cm.Title Confusion Matrix for Test Data;
cm.ColumnSummary column-normalized;
cm.RowSummary row-normalized;
参考资料 [1] http://t.csdn.cn/pCWSp [2] https://download.csdn.net/download/kjm13182345320/87568090?spm1001.2014.3001.5501 [3] https://blog.csdn.net/kjm13182345320/article/details/129433463?spm1001.2014.3001.5501