多维时序 | MATLAB实现VMD-SSA-KELM和VMD-KELM变分模态分解结合麻雀算法优化核极限学习机多输入单输出时间序列预测
请尊重原创劳动成果
转载请注明本文链接
及文章作者:机器学习之心
预测效果
使用教程
1 基本介绍
MATLAB实现VMD-SSA-KELM和VMD-KELM变分模态分解结合麻雀算法优化核极限学习机多输入单输出时间序列预测
2 网络结构
设置网络参数
vmd(YData,'NumIMFs',3)
vmd(YData,'NumIMFs',3); =
Data=[imf res];
input = xlsread('WTData.xlsx', 'Sheet1', 'B2:H3673'); % 影响因素
for k = 1 : size(Data, 2)
',num2str(k),' 个分量的预测: '])
,k) = Data(:, k); :
delay=1; %时滞
data1 = [];
for i=1:length(data(:,k))-delay
)=data(i:i+delay,k)'; :
end
data1 = [input(delay+1:end,:),data1];
P = data1(:,1:end-1);
T = data1(:,end);
设定训练集与测试集
Len = size(data1, 1);
testNum = 300;
testNum = round(Len*0.3);
trainNum = Len - testNum;
训练集
P_train = P(1:trainNum, :)';
T_train = T(1:trainNum, :)';
测试集
P_test = P(trainNum+1:trainNum+testNum,:)';
T_test = T(trainNum+1:trainNum+testNum,:)';
归一化
,ps]= mapminmax(P_train, 0, 1);
ts] = mapminmax(T_train, 0, 1);
%测试集的归一化
Pn_test = mapminmax('apply', P_test, ps);
Tn_test = mapminmax('apply', T_test, ts);
麻雀参数设置
pop=20; %种群数量
Max_iteration=30; % 设定最大迭代次数
dim = 2;% 维度为2,即优化两个参数,正则化系数 C 和核函数参数 S
lb = [0.001,0.001];%下边界
ub = [50,50];%上边界
fobj = @(x) fun(x,Pn_train,Tn_train,Pn_test,T_test,ts);
SSA(pop,Max_iteration,lb,ub,dim,fobj); %开始优化 =
figure
plot(SSA_curve,'linewidth',1.5);
grid on;
of iteration')
function')
convergence curve')
'Times New Roman');
获取最优正则化系数 C 和核函数参数 S
Regularization_coefficient = Best_pos(1);
Kernel_para = Best_pos(2);
Kernel_type = 'rbf';
训练
kelmTrain(Pn_train,Tn_train,Regularization_coefficient,Kernel_type,Kernel_para); =
测试
InputWeight = OutputWeight;
kelmPredict(Pn_train,InputWeight,Kernel_type,Kernel_para,Pn_test); =
) = mapminmax('reverse',TestOutT,ts); :
基础KELM进行预测
Regularization_coefficient1 = 2;
Kernel_para1 = [4]; %核函数参数矩阵
Kernel_type = 'rbf';
训练
kelmTrain(Pn_train,Tn_train,Regularization_coefficient1,Kernel_type,Kernel_para1); =
预测
InputWeight1 = OutputWeight1;
kelmPredict(Pn_train,InputWeight1,Kernel_type,Kernel_para1,Pn_test); =
) = mapminmax('reverse',TestOutT1,ts); :
end
完整代码
注意:
class
% @author : 机器学习之心
% 完整代码:https://mbd.pub/o/bread/mbd-Y56VlZZt
% @author : 机器学习之心
end
完
属实不易,如果有用请留个赞
叭~
未经允许本代码请勿作商业用途!!!