回归预测 | Matlab实现SSA-CNN-SVM麻雀算法优化卷积神经网络-支持向量机的多输入单输出回归预测
目录
效果一览
基本介绍
1.SSA-CNN-SVM麻雀算法优化卷积神经网络-支持向量机的多变量回归预测 可直接运行Matlab;
2.评价指标包括: R2、MAE、RMSE和MAPE等,代码质量极高,方便学习和替换数据。要求2021版本及以上。
3.麻雀算法SSA优化的参数为:CNN的批处理大小、学习率、正则化系数,能够避免人工选取参数的盲目性,有效提高其预测精度。
4.main.m为主程序,其他为函数文件,无需运行,data为数据,多输入单输出,数据回归预测,输入7个特征,输出1个变量,直接替换Excel数据即可用!注释清晰,适合新手小白~
程序设计
- 完整程序和数据获取方式:私信博主回复回归预测 | Matlab实现SSA-CNN-SVM麻雀算法优化卷积神经网络-支持向量机的多输入单输出回归预测;
python
ST = 0.7;%预警值
PD = 0.4;%发现者的比列,剩下的是加入者0.7
SD = 0.2;%意识到有危险麻雀的比重
PDNumber = round(pop*PD); %发现者数量
SDNumber = round(SD*PD);%意识到有危险麻雀数量
%种群初始化
X0=initialization(pop,dim,ub,lb);
X = X0;
%计算初始适应度值
fitness = zeros(1,pop);
for i = 1:pop
fitness(i) = fobj(X(i,:));
end
[fitness, index]= sort(fitness);%升排序
BestF = fitness(1);
WorstF = fitness(end);
GBestF = fitness(1);%全局最优适应度值
for i = 1:pop
X(i,:) = X0(index(i),:);
end
curve=zeros(1,Max_iter);
GBestX = X(1,:);%全局最优位置
X_new = X;
for i = 1: Max_iter
disp(['第',num2str(i),'次迭代'])
BestF = fitness(1);
WorstF = fitness(end);
R2 = rand(1);
for j = 1:PDNumber
if(R2<ST)
X_new(j,:) = X(j,:).*exp(-j/(rand(1)*Max_iter));
else
X_new(j,:) = X(j,:) + randn()*ones(1,dim);
end
end
for j = PDNumber+1:pop
% if(j>(pop/2))
if(j>(pop - PDNumber)/2 + PDNumber)
X_new(j,:)= randn().*exp((X(end,:) - X(j,:))/j^2);
else
%产生-1,1的随机数
A = ones(1,dim);
for a = 1:dim
if(rand()>0.5)
A(a) = -1;
end
end
AA = A'*inv(A*A');
X_new(j,:)= X(1,:) + abs(X(j,:) - X(1,:)).*AA';
end
end
Temp = randperm(pop);
SDchooseIndex = Temp(1:SDNumber);
for j = 1:SDNumber
if(fitness(SDchooseIndex(j))>BestF)
X_new(SDchooseIndex(j),:) = X(1,:) + randn().*abs(X(SDchooseIndex(j),:) - X(1,:));
elseif(fitness(SDchooseIndex(j))== BestF)
K = 2*rand() -1;
X_new(SDchooseIndex(j),:) = X(SDchooseIndex(j),:) + K.*(abs( X(SDchooseIndex(j),:) - X(end,:))./(fitness(SDchooseIndex(j)) - fitness(end) + 10^-8));
end
end
%边界控制
参考资料
[1] https://blog.csdn.net/kjm13182345320/article/details/129036772?spm=1001.2014.3001.5502
[2] https://blog.csdn.net/kjm13182345320/article/details/128690229