当前位置:首页 » 《随便一记》 » 正文

回归预测 | Matlab实现DE-BP差分算法优化BP神经网络多变量回归预测

24 人参与  2024年02月19日 13:01  分类 : 《随便一记》  评论

点击全文阅读


回归预测 | Matlab实现DE-BP差分算法优化BP神经网络多变量回归预测

目录

回归预测 | Matlab实现DE-BP差分算法优化BP神经网络多变量回归预测效果一览基本介绍程序设计参考资料

效果一览

在这里插入图片描述
在这里插入图片描述
在这里插入图片描述

基本介绍

1.Matlab实现DE-BP差分算法优化BP神经网络多变量回归预测(完整源码和数据)
2.运行环境为Matlab2018b;
3.excel数据集,输入多个特征,输出单个变量,多变量回归预测预测,DE_BP.m为主程序,运行即可,所有文件放在一个文件夹;
4.输出优化前后对比图,误差对比图;
代码特点:参数化编程、参数可方便更改、代码编程思路清晰、注释明细。

程序设计

完整源码和数据获取方式(资源处下载):Matlab实现DE-BP差分算法优化BP神经网络多变量回归预测。
%%  清空环境变量%选连样本输入输出数据归一化[inputn,inputps]=mapminmax(input_train);[outputn,outputps]=mapminmax(output_train);%构建网络net=newff(inputn,outputn,hiddennum);%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%优化前的BPnet.trainParam.epochs=100;net.trainParam.lr=0.1;net.trainParam.goal=0.00001;[net,~]=train(net,inputn,outputn);inputn_test=mapminmax('apply',input_test,inputps);an=sim(net,inputn_test);%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 利用差分进化算法选择最佳的BP参数D=inputnum*hiddennum+hiddennum+hiddennum*outputnum+outputnum;%变量个数%变量的维数NP=5;                                %个体数目                               G=30;                                %最大进化代数%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%Xs=1*ones(D,1);                                 %上限Xx=-1*ones(D,1);                                %下限%%%%%%%%%%%%%%%%%%%%%%%%%赋初值%%%%%%%%%%%%%%%%%%%%%%%%   xx=zeros(D,NP);                        %初始种群v=zeros(D,NP);                        %变异种群u=zeros(D,NP);                        %选择种群xchu=rand(D,NP);for i=1:NPxx(:,i)=xchu(:,i).*(Xs-Xx)+Xx;              %赋初始种群初值end%%%%%%%%%%%%%%%%%%%%计算目标函数%%%%%%%%%%%%%%%%%%%%%%%trace(1)=min(Ob);gbest=100;%%%%%%%%%%%%%%%%%%%%%%%差分进化循环%%%%%%%%%%%%%%%%%%%%%for gen=1:G    %%%%%%%%%%%%%%%%%%%%%%变异操作%%%%%%%%%%%%%%%%%%%%%%    %%%%%%%%%%%%%%%%%%r1,r2,r3和m互不相同%%%%%%%%%%%%%%%    for m=1:NP        r1=randi([1,NP],1,1);        while (r1==m)            r1=randi([1,NP],1,1);        end        r2=randi([1,NP],1,1);        while (r2==m)||(r2==r1)            r2=randi([1,NP],1,1);        end        r3=randi([1,NP],1,1);        while (r3==m)||(r3==r1)||(r3==r2)            r3=randi([1,NP],1,1);        end        v(:,m)=xx(:,r1)+F*(xx(:,r2)-xx(:,r3));    end    %%%%%%%%%%%%%%%%%%%%%%交叉操作%%%%%%%%%%%%%%%%%%%%%%%    r=randi([1,D],1,1);    for n=1:D        cr=rand(1);        if (cr<=CR)||(n==r)            u(n,:)=v(n,:);        else            u(n,:)=xx(n,:);        end    end    %%%%%%%%%%%%%%%%%%%边界条件的处理%%%%%%%%%%%%%%%%%%%%    %%%%%%%%%%%%%%%%%%%%边界吸收%%%%%%%%%%%%%%%%%%%%%%%%%    for n=1:D        for m=1:NP            if u(n,m)<Xx(n)                u(n,m)=Xx(n);            end            if u(n,m)>Xs(n)                u(n,m)=Xs(n);            end        end    end    %%%%%%%%%%%%%%%%%%%%%%选择操作%%%%%%%%%%%%%%%%%%%%%%%    for m=1:NP        Ob1(m)=fitness(u(:,m));    end    for m=1:NP        if Ob1(m)<Ob(m)            xx(:,m)=u(:,m);        end    end    for m=1:NP        Ob(m)=fitness(xx(:,m));    end    fbest=min(Ob);    if(fbest<gbest)                gbest=fbest;        histor(gen)=fbest;    else        histor(gen)=gbest;    endend

参考资料

[1] https://blog.csdn.net/kjm13182345320/article/details/129215161
[2] https://blog.csdn.net/kjm13182345320/article/details/128105718


点击全文阅读


本文链接:http://zhangshiyu.com/post/69057.html

<< 上一篇 下一篇 >>

  • 评论(0)
  • 赞助本站

◎欢迎参与讨论,请在这里发表您的看法、交流您的观点。

关于我们 | 我要投稿 | 免责申明

Copyright © 2020-2022 ZhangShiYu.com Rights Reserved.豫ICP备2022013469号-1