多输入多输出 | MATLAB实现LSSVM最小二乘支持向量机多输入多输出
目录
预测效果
基本介绍
MATLAB实现LSSVM最小二乘支持向量机多输入多输出
1.data为数据集,10个输入特征,3个输出变量。
2.main.m为主程序文件。
3.命令窗口输出MBE、MAE和R2,可在下载区获取数据和程序内容。
程序设计
- 完整程序和数据下载方式:私信博主回复MATLAB实现LSSVM最小二乘支持向量机多输入多输出。
clike
%-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
%% 参数初始化
c1 = 4.494; % 学习因子
c2 = 4.494; % 学习因子
maxgen = 50; % 种群更新次数
sizepop = 5; % 种群规模
Vmax = 1.0; % 最大速度
Vmin = -1.0; % 最小速度
popmax = 1.0; % 最大边界
popmin = -1.0; % 最小边界
%-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
for i = 1 : sizepop
pop(i, :) = rands(1, numsum); % 初始化种群
V(i, :) = rands(1, numsum); % 初始化速度
fitness(i) = fun(pop(i, :), hiddennum, net, p_train, t_train);
end
%-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
%% 个体极值和群体极值
[fitnesszbest, bestindex] = min(fitness);
zbest = pop(bestindex, :); % 全局最佳
gbest = pop; % 个体最佳
fitnessgbest = fitness; % 个体最佳适应度值
BestFit = fitnesszbest; % 全局最佳适应度值
%-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
%% 迭代寻优
for i = 1 : maxgen
for j = 1 : sizepop
% 速度更新
V(j, :) = V(j, :) + c1 * rand * (gbest(j, :) - pop(j, :)) + c2 * rand * (zbest - pop(j, :));
V(j, (V(j, :) > Vmax)) = Vmax;
V(j, (V(j, :) < Vmin)) = Vmin;
% 种群更新
pop(j, :) = pop(j, :) + 0.2 * V(j, :);
pop(j, (pop(j, :) > popmax)) = popmax;
pop(j, (pop(j, :) < popmin)) = popmin;
% 适应度值
fitness(j) = fun(pop(j, :), hiddennum, net, p_train, t_train);
end
for j = 1 : sizepop
% 个体最优更新
if fitness(j) < fitnessgbest(j)
gbest(j, :) = pop(j, :);
fitnessgbest(j) = fitness(j);
end
end
BestFit = [BestFit, fitnesszbest];
end
往期精彩
MATLAB实现RBF径向基神经网络多输入多输出预测
MATLAB实现BP神经网络多输入多输出预测
MATLAB实现DNN神经网络多输入多输出预测
参考资料
[1] https://blog.csdn.net/kjm13182345320/article/details/116377961
[2] https://blog.csdn.net/kjm13182345320/article/details/127931217
[3] https://blog.csdn.net/kjm13182345320/article/details/127894261