1 简介
近年来,已有越来越多的建模方法被相关学者提出用来解决分类识别、风险预测、效能评估等问题,这些建模方法包括:时间序列分析、灰色理论、神经网络等。但是时间序列分析,方法复杂且预测精度较低;灰色理论需要规律性的数据;神经网络方法易出现过拟合以及易陷入局部极值等问题。支持向量机((Support Vector Machine,SVM)是一种基于结构风险最小化且有着强大的泛化能力的建模方法。它可以很好地解决小样本、非线性,以及陷入局部极值等问题。然而,SVM的学习能力和泛化能力取决于合适的参数选择,这些参数直接影响了模型的性能。因此,近年来越来越多的参数优化方法被应用于 SVM的参数选择问题,比如网格搜索法、粒子群算法、蝙蝠算法等,然而网格搜索法运算量大,搜索效率低;粒子群算法和蝙蝠算法在参数寻优过程中会出现收敛速度慢、易陷入局部极值的问题。本文提出的 GWO—SVM模型,仿真结果表明,该模型预测精度较高。
2 部分代码
clc
clear all
close all
n=30; % Population size, typically 10 to 25
p=0.8; % probabibility switch
% Iteration parameters
N_iter=3000; % Total number of iterations
fitnessMSE = ones(1,N_iter);
% % Dimension of the search variables Example 1
d=2;
Lb = -1*ones(1,d);
Ub = 1*ones(1,d);
% % Dimension of the search variables Example 2
% d=3;
% Lb = [-2 -1 -1];
% Ub = [2 1 1];
%
% % Dimension of the search variables Example 3
% d=3;
% Lb = [-1 -1 -1];
% Ub = [1 1 1];
%
%
% % % Dimension of the search variables Example 4
% d=9;
% Lb = -1.5*ones(1,d);
% Ub = 1.5*ones(1,d);
% Initialize the population/solutions
for i=1:n,
Sol(i,:)=Lb+(Ub-Lb).*rand(1,d);
% To simulate the filters use fitnessX() functions in the next line
Fitness(i)=fitness(Sol(i,:));
end
% Find the current best
[fmin,I]=min(Fitness);
best=Sol(I,:);
S=Sol;
% Start the iterations -- Flower Algorithm
for t=1:N_iter,
% Loop over all bats/solutions
for i=1:n,
% Pollens are carried by insects and thus can move in
% large scale, large distance.
% This L should replace by Levy flights
% Formula: x_i^{t+1}=x_i^t+ L (x_i^t-gbest)
if rand>p,
%% L=rand;
L=Levy(d);
dS=L.*(Sol(i,:)-best);
S(i,:)=Sol(i,:)+dS;
% Check if the simple limits/bounds are OK
S(i,:)=simplebounds(S(i,:),Lb,Ub);
% If not, then local pollenation of neighbor flowers
else
epsilon=rand;
% Find random flowers in the neighbourhood
JK=randperm(n);
% As they are random, the first two entries also random
% If the flower are the same or similar species, then
% they can be pollenated, otherwise, no action.
% Formula: x_i^{t+1}+epsilon*(x_j^t-x_k^t)
S(i,:)=S(i,:)+epsilon*(Sol(JK(1),:)-Sol(JK(2),:));
% Check if the simple limits/bounds are OK
S(i,:)=simplebounds(S(i,:),Lb,Ub);
end
% Evaluate new solutions
% To simulate the filters use fitnessX() functions in the next
% line
Fnew=fitness(S(i,:));
% If fitness improves (better solutions found), update then
if (Fnew<=Fitness(i)),
Sol(i,:)=S(i,:);
Fitness(i)=Fnew;
end
% Update the current global best
if Fnew<=fmin,
best=S(i,:) ;
fmin=Fnew ;
end
end
% Display results every 100 iterations
if round(t/100)==t/100,
best
fmin
end
fitnessMSE(t) = fmin;
end
%figure, plot(1:N_iter,fitnessMSE);
% Output/display
disp(['Total number of evaluations: ',num2str(N_iter*n)]);
disp(['Best solution=',num2str(best),' fmin=',num2str(fmin)]);
figure(1)
plot( fitnessMSE)
xlabel('Iteration');
ylabel('Best score obtained so far');
3 仿真结果
4 参考文献
[1]王玉鑫, 李东生, & 高杨. (2018). 基于改进型花朵授粉算法的svm参数优化. 火力与指挥控制, 43(10), 6.
部分理论引用网络文献,若有侵权联系博主删除。