1.Matlab基于OOA-SVR鱼鹰算法优化支持向量机的数据多输入单输出回归预测(完整源码和数据)
2.OOA选择最佳的SVM核函数参数c和g;
3.多特征输入单输出的回归预测。程序内注释详细,excel数据,直接替换数据就可以用。
4.程序语言为matlab,程序可出预测效果图,迭代优化图,相关分析图,运行环境matlab2020b及以上。评价指标包括:R2、RPD、MSE、RMSE、MAE、MAPE等。
5.代码特点:参数化编程、参数可方便更改、代码编程思路清晰、注释明细。
%% 参数设置
%% 优化算法
[Best_score,Best_pos, curve] = OOA(pop, Max_iteration, lb, ub, dim, fun);
%% 获取最优参数
bestc = Best_pos(1, 1);
bestg = Best_pos(1, 2);
%% 建立模型
cmd = [' -t 2 ', ' -c ', num2str(bestc), ' -g ', num2str(bestg), ' -s 3 -p 0.01 '];
model = svmtrain(t_train, p_train, cmd);
%% 仿真预测
[t_sim1, error_1] = svmpredict(t_train, p_train, model);
[t_sim2, error_2] = svmpredict(t_test , p_test , model);
%% 数据反归一化
T_sim1 = mapminmax('reverse', t_sim1, ps_output);
T_sim2 = mapminmax('reverse', t_sim2, ps_output);
T_sim1 =T_sim1';
T_sim2 =T_sim2';
%% 适应度曲线
figure;
plot(1 : length(curve), curve, 'LineWidth', 1.5);
title('适应度曲线', 'FontSize', 13);
xlabel('迭代次数', 'FontSize', 13);
ylabel('适应度值', 'FontSize', 13);
grid
set(gcf,'color','w')
%% 相关指标计算
%% 均方根误差
toc
%% 测试集结果
figure;
plotregression(T_test,T_sim2,['回归图']);
set(gcf,'color','w')
figure;
ploterrhist(T_test-T_sim2,['误差直方图']);
set(gcf,'color','w')
%% 均方根误差 RMSE
error1 = sqrt(sum((T_sim1 - T_train).^2)./M);
error2 = sqrt(sum((T_test - T_sim2).^2)./N);
%%
%决定系数
R1 = 1 - norm(T_train - T_sim1)^2 / norm(T_train - mean(T_train))^2;
R2 = 1 - norm(T_test - T_sim2)^2 / norm(T_test - mean(T_test ))^2;
%%
%均方误差 MSE
mse1 = sum((T_sim1 - T_train).^2)./M;
mse2 = sum((T_sim2 - T_test).^2)./N;
%%
%RPD 剩余预测残差
SE1=std(T_sim1-T_train);
RPD1=std(T_train)/SE1;
SE=std(T_sim2-T_test);
RPD2=std(T_test)/SE;
%% 平均绝对误差MAE
MAE1 = mean(abs(T_train - T_sim1));
MAE2 = mean(abs(T_test - T_sim2));
%% 平均绝对百分比误差MAPE
MAPE1 = mean(abs((T_train - T_sim1)./T_train));
MAPE2 = mean(abs((T_test - T_sim2)./T_test));
[1] https://blog.csdn.net/kjm13182345320/article/details/129036772?spm=1001.2014.3001.5502
[2] https://blog.csdn.net/kjm13182345320/article/details/128690229